Commit be5d0864 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpd: Add -c, --header-table-size option

parent d92a161c
...@@ -73,7 +73,8 @@ Config::Config() ...@@ -73,7 +73,8 @@ Config::Config()
verify_client(false), verify_client(false),
no_tls(false), no_tls(false),
no_flow_control(false), no_flow_control(false),
output_upper_thres(1024*1024) output_upper_thres(1024*1024),
header_table_size(-1)
{} {}
Request::Request(int32_t stream_id) Request::Request(int32_t stream_id)
...@@ -362,7 +363,7 @@ int Http2Handler::on_connect() ...@@ -362,7 +363,7 @@ int Http2Handler::on_connect()
if(r != 0) { if(r != 0) {
return r; return r;
} }
nghttp2_settings_entry entry[2]; nghttp2_settings_entry entry[3];
size_t niv = 1; size_t niv = 1;
entry[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; entry[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS;
entry[0].value = 100; entry[0].value = 100;
...@@ -371,6 +372,11 @@ int Http2Handler::on_connect() ...@@ -371,6 +372,11 @@ int Http2Handler::on_connect()
entry[niv].value = 1; entry[niv].value = 1;
++niv; ++niv;
} }
if(config.header_table_size >= 0) {
entry[niv].settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE;
entry[niv].value = config.header_table_size;
++niv;
}
r = nghttp2_submit_settings(session_, NGHTTP2_FLAG_NONE, entry, niv); r = nghttp2_submit_settings(session_, NGHTTP2_FLAG_NONE, entry, niv);
if(r != 0) { if(r != 0) {
return r; return r;
......
...@@ -60,6 +60,7 @@ struct Config { ...@@ -60,6 +60,7 @@ struct Config {
bool no_tls; bool no_tls;
bool no_flow_control; bool no_flow_control;
size_t output_upper_thres; size_t output_upper_thres;
ssize_t header_table_size;
Config(); Config();
}; };
......
...@@ -76,6 +76,8 @@ void print_help(std::ostream& out) ...@@ -76,6 +76,8 @@ void print_help(std::ostream& out)
<< " -f, --no-flow-control\n" << " -f, --no-flow-control\n"
<< " Disables connection and stream level flow\n" << " Disables connection and stream level flow\n"
<< " controls.\n" << " controls.\n"
<< " -c, --header-table-size=<N>\n"
<< " Specify decoder header table size.\n"
<< " --color Force colored log output.\n" << " --color Force colored log output.\n"
<< " -h, --help Print this help.\n" << " -h, --help Print this help.\n"
<< std::endl; << std::endl;
...@@ -95,12 +97,14 @@ int main(int argc, char **argv) ...@@ -95,12 +97,14 @@ int main(int argc, char **argv)
{"verbose", no_argument, nullptr, 'v'}, {"verbose", no_argument, nullptr, 'v'},
{"verify-client", no_argument, nullptr, 'V'}, {"verify-client", no_argument, nullptr, 'V'},
{"no-flow-control", no_argument, nullptr, 'f'}, {"no-flow-control", no_argument, nullptr, 'f'},
{"header-table-size", required_argument, nullptr, 'c'},
{"no-tls", no_argument, &flag, 1}, {"no-tls", no_argument, &flag, 1},
{"color", no_argument, &flag, 2}, {"color", no_argument, &flag, 2},
{nullptr, 0, nullptr, 0} {nullptr, 0, nullptr, 0}
}; };
int option_index = 0; int option_index = 0;
int c = getopt_long(argc, argv, "DVd:fhv", long_options, &option_index); int c = getopt_long(argc, argv, "DVc:d:fhv", long_options, &option_index);
char *end;
if(c == -1) { if(c == -1) {
break; break;
} }
...@@ -123,6 +127,13 @@ int main(int argc, char **argv) ...@@ -123,6 +127,13 @@ int main(int argc, char **argv)
case 'v': case 'v':
config.verbose = true; config.verbose = true;
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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment