nghttpd: Add -c, --header-table-size option
This commit is contained in:
parent
d92a161c46
commit
be5d08647e
|
@ -73,7 +73,8 @@ Config::Config()
|
|||
verify_client(false),
|
||||
no_tls(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)
|
||||
|
@ -362,7 +363,7 @@ int Http2Handler::on_connect()
|
|||
if(r != 0) {
|
||||
return r;
|
||||
}
|
||||
nghttp2_settings_entry entry[2];
|
||||
nghttp2_settings_entry entry[3];
|
||||
size_t niv = 1;
|
||||
entry[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS;
|
||||
entry[0].value = 100;
|
||||
|
@ -371,6 +372,11 @@ int Http2Handler::on_connect()
|
|||
entry[niv].value = 1;
|
||||
++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);
|
||||
if(r != 0) {
|
||||
return r;
|
||||
|
|
|
@ -60,6 +60,7 @@ struct Config {
|
|||
bool no_tls;
|
||||
bool no_flow_control;
|
||||
size_t output_upper_thres;
|
||||
ssize_t header_table_size;
|
||||
Config();
|
||||
};
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@ void print_help(std::ostream& out)
|
|||
<< " -f, --no-flow-control\n"
|
||||
<< " Disables connection and stream level flow\n"
|
||||
<< " controls.\n"
|
||||
<< " -c, --header-table-size=<N>\n"
|
||||
<< " Specify decoder header table size.\n"
|
||||
<< " --color Force colored log output.\n"
|
||||
<< " -h, --help Print this help.\n"
|
||||
<< std::endl;
|
||||
|
@ -95,12 +97,14 @@ int main(int argc, char **argv)
|
|||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{"verify-client", no_argument, nullptr, 'V'},
|
||||
{"no-flow-control", no_argument, nullptr, 'f'},
|
||||
{"header-table-size", required_argument, nullptr, 'c'},
|
||||
{"no-tls", no_argument, &flag, 1},
|
||||
{"color", no_argument, &flag, 2},
|
||||
{nullptr, 0, nullptr, 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) {
|
||||
break;
|
||||
}
|
||||
|
@ -123,6 +127,13 @@ int main(int argc, char **argv)
|
|||
case 'v':
|
||||
config.verbose = true;
|
||||
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 '?':
|
||||
exit(EXIT_FAILURE);
|
||||
case 0:
|
||||
|
|
Loading…
Reference in New Issue