nghttp: Add --header-table-size option

This commit is contained in:
Tatsuhiro Tsujikawa 2013-10-29 21:34:22 +09:00
parent 57f1b950ef
commit 535329779c
1 changed files with 20 additions and 2 deletions

View File

@ -96,6 +96,7 @@ struct Config {
std::string datafile; std::string datafile;
size_t output_upper_thres; size_t output_upper_thres;
ssize_t peer_max_concurrent_streams; ssize_t peer_max_concurrent_streams;
ssize_t header_table_size;
Config() Config()
: null_out(false), : null_out(false),
remote_name(false), remote_name(false),
@ -110,7 +111,8 @@ struct Config {
window_bits(-1), window_bits(-1),
connection_window_bits(-1), connection_window_bits(-1),
output_upper_thres(1024*1024), output_upper_thres(1024*1024),
peer_max_concurrent_streams(NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS) peer_max_concurrent_streams(NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS),
header_table_size(-1)
{} {}
}; };
} // namespace } // namespace
@ -363,6 +365,11 @@ size_t populate_settings(nghttp2_settings_entry *iv)
iv[niv].value = 1; iv[niv].value = 1;
++niv; ++niv;
} }
if(config.header_table_size >= 0) {
iv[niv].settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE;
iv[niv].value = config.header_table_size;
++niv;
}
return niv; return niv;
} }
} // namespace } // namespace
@ -1610,6 +1617,8 @@ void print_help(std::ostream& out)
<< " value of remote endpoint as if it is\n" << " value of remote endpoint as if it is\n"
<< " received in SETTINGS frame. The default\n" << " received in SETTINGS frame. The default\n"
<< " is large enough as it is seen as unlimited.\n" << " is large enough as it is seen as unlimited.\n"
<< " -c, --header-table-size=<N>\n"
<< " Specify decoder header table size.\n"
<< std::endl; << std::endl;
} }
} // namespace } // namespace
@ -1637,11 +1646,13 @@ int main(int argc, char **argv)
{"upgrade", no_argument, nullptr, 'u'}, {"upgrade", no_argument, nullptr, 'u'},
{"pri", required_argument, nullptr, 'p'}, {"pri", required_argument, nullptr, 'p'},
{"peer-max-concurrent-streams", required_argument, nullptr, 'M'}, {"peer-max-concurrent-streams", required_argument, nullptr, 'M'},
{"header-table-size", required_argument, nullptr, 'c'},
{nullptr, 0, nullptr, 0 } {nullptr, 0, nullptr, 0 }
}; };
int option_index = 0; int option_index = 0;
int c = getopt_long(argc, argv, "M:Oad:fm:np:hH:vst:uw:W:", long_options, int c = getopt_long(argc, argv, "M:Oac:d:fm:np:hH:vst:uw:W:", long_options,
&option_index); &option_index);
char *end;
if(c == -1) { if(c == -1) {
break; break;
} }
@ -1744,6 +1755,13 @@ int main(int argc, char **argv)
case 'm': case 'm':
config.multiply = strtoul(optarg, nullptr, 10); config.multiply = strtoul(optarg, nullptr, 10);
break; break;
case 'c':
config.header_table_size = strtol(optarg, &end, 10);
if(errno == ERANGE || *end != '\0') {
std::cerr << "-c: Bad option value: " << optarg << std::endl;
exit(EXIT_FAILURE);
}
break;
case '?': case '?':
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
case 0: case 0: