Skip to content

Commit

Permalink
nghttp: Add --no-push option to disable server push
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Apr 17, 2015
1 parent 0b41e20 commit c4e994c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/nghttp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -745,7 +752,7 @@ int HttpClient::on_upgrade_connect() {
ssize_t rv;
record_connect_end_time();
assert(!reqvec.empty());
std::array<nghttp2_settings_entry, 32> iv;
std::array<nghttp2_settings_entry, 16> iv;
size_t niv = populate_settings(iv.data());
assert(settings_payload.size() >= 8 * niv);
rv = nghttp2_pack_settings_payload(settings_payload.data(),
Expand Down Expand Up @@ -2372,6 +2379,7 @@ void print_help(std::ostream &out) {
--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.
Expand Down Expand Up @@ -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:",
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/nghttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit c4e994c

Please sign in to comment.