diff --git a/src/nghttp.cc b/src/nghttp.cc index 988d1b48..2d143200 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -95,6 +95,7 @@ constexpr auto anchors = std::array{{ Config::Config() : header_table_size(-1), min_header_table_size(std::numeric_limits::max()), + encoder_header_table_size(-1), padding(0), max_concurrent_streams(100), peer_max_concurrent_streams(100), @@ -2619,6 +2620,11 @@ Options: the last value, that minimum value is set in SETTINGS frame payload before the last value, to simulate multiple header table size change. + --encoder-header-table-size= + Specify encoder header table size. The decoder (server) + specifies the maximum dynamic table size it accepts. + Then the negotiated dynamic table size is the minimum of + this option value and the value which server specified. -b, --padding= Add at most bytes to a frame payload as padding. Specify 0 to disable padding. @@ -2695,6 +2701,7 @@ int main(int argc, char **argv) { {"no-push", no_argument, &flag, 11}, {"max-concurrent-streams", required_argument, &flag, 12}, {"expect-continue", no_argument, &flag, 13}, + {"encoder-header-table-size", required_argument, &flag, 14}, {nullptr, 0, nullptr, 0}}; int option_index = 0; int c = getopt_long(argc, argv, "M:Oab:c:d:gm:np:r:hH:vst:uw:W:", @@ -2896,6 +2903,23 @@ int main(int argc, char **argv) { // expect-continue option config.expect_continue = true; break; + case 14: { + // encoder-header-table-size option + auto n = util::parse_uint_with_unit(optarg); + if (n == -1) { + std::cerr << "--encoder-header-table-size: Bad option value: " + << optarg << std::endl; + exit(EXIT_FAILURE); + } + if (n > std::numeric_limits::max()) { + std::cerr << "--encoder-header-table-size: Value too large. It " + "should be less than or equal to " + << std::numeric_limits::max() << std::endl; + exit(EXIT_FAILURE); + } + config.encoder_header_table_size = n; + break; + } } break; default: @@ -2916,6 +2940,11 @@ int main(int argc, char **argv) { nghttp2_option_set_peer_max_concurrent_streams( config.http2_option, config.peer_max_concurrent_streams); + if (config.encoder_header_table_size != -1) { + nghttp2_option_set_max_deflate_dynamic_table_size( + config.http2_option, config.encoder_header_table_size); + } + struct sigaction act {}; act.sa_handler = SIG_IGN; sigaction(SIGPIPE, &act, nullptr); diff --git a/src/nghttp.h b/src/nghttp.h index b45cf614..eb36a4ce 100644 --- a/src/nghttp.h +++ b/src/nghttp.h @@ -72,6 +72,7 @@ struct Config { nghttp2_option *http2_option; int64_t header_table_size; int64_t min_header_table_size; + int64_t encoder_header_table_size; size_t padding; size_t max_concurrent_streams; ssize_t peer_max_concurrent_streams;