From c4e994c97d21ab7bd5032b6887a4ada73b641a90 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 17 Apr 2015 23:34:28 +0900 Subject: [PATCH] nghttp: Add --no-push option to disable server push --- src/nghttp.cc | 17 +++++++++++++++-- src/nghttp.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/nghttp.cc b/src/nghttp.cc index f03704f5..56e09ec9 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -95,7 +95,7 @@ Config::Config() timeout(0.), window_bits(-1), connection_window_bits(-1), verbose(0), null_out(false), remote_name(false), get_assets(false), stat(false), upgrade(false), continuation(false), no_content_length(false), - no_dep(false), hexdump(false) { + no_dep(false), hexdump(false), no_push(false) { nghttp2_option_new(&http2_option); nghttp2_option_set_peer_max_concurrent_streams(http2_option, peer_max_concurrent_streams); @@ -737,6 +737,13 @@ size_t populate_settings(nghttp2_settings_entry *iv) { iv[niv].value = config.header_table_size; ++niv; } + + if (config.no_push) { + iv[niv].settings_id = NGHTTP2_SETTINGS_ENABLE_PUSH; + iv[niv].value = 0; + ++niv; + } + return niv; } } // namespace @@ -745,7 +752,7 @@ int HttpClient::on_upgrade_connect() { ssize_t rv; record_connect_end_time(); assert(!reqvec.empty()); - std::array iv; + std::array iv; size_t niv = populate_settings(iv.data()); assert(settings_payload.size() >= 8 * niv); rv = nghttp2_pack_settings_payload(settings_payload.data(), @@ -2372,6 +2379,7 @@ Options: --hexdump Display the incoming traffic in hexadecimal (Canonical hex+ASCII display). If SSL/TLS is used, decrypted data are used. + --no-push Disable server push. --version Display version information and exit. -h, --help Display this help and exit. @@ -2414,6 +2422,7 @@ int main(int argc, char **argv) { {"no-dep", no_argument, &flag, 7}, {"trailer", required_argument, &flag, 9}, {"hexdump", no_argument, &flag, 10}, + {"no-push", no_argument, &flag, 11}, {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:", @@ -2597,6 +2606,10 @@ int main(int argc, char **argv) { // hexdump option config.hexdump = true; break; + case 11: + // no-push option + config.no_push = true; + break; } break; default: diff --git a/src/nghttp.h b/src/nghttp.h index 02421fc5..67e94722 100644 --- a/src/nghttp.h +++ b/src/nghttp.h @@ -84,6 +84,7 @@ struct Config { bool no_content_length; bool no_dep; bool hexdump; + bool no_push; }; enum class RequestState { INITIAL, ON_REQUEST, ON_RESPONSE, ON_COMPLETE };