Commit fadbdbae authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttp: Add -p option to specify stream priority

parent 2a311b31
...@@ -83,6 +83,7 @@ struct Config { ...@@ -83,6 +83,7 @@ struct Config {
bool no_connection_flow_control; bool no_connection_flow_control;
bool no_stream_flow_control; bool no_stream_flow_control;
bool upgrade; bool upgrade;
int32_t pri;
int multiply; int multiply;
// milliseconds // milliseconds
int timeout; int timeout;
...@@ -102,6 +103,7 @@ struct Config { ...@@ -102,6 +103,7 @@ struct Config {
no_connection_flow_control(false), no_connection_flow_control(false),
no_stream_flow_control(false), no_stream_flow_control(false),
upgrade(false), upgrade(false),
pri(NGHTTP2_PRI_DEFAULT),
multiply(1), multiply(1),
timeout(-1), timeout(-1),
window_bits(-1), window_bits(-1),
...@@ -895,7 +897,7 @@ void submit_request(HttpClient *client, ...@@ -895,7 +897,7 @@ void submit_request(HttpClient *client,
} }
nv[pos] = nullptr; nv[pos] = nullptr;
int r = nghttp2_submit_request(client->session, NGHTTP2_PRI_DEFAULT, int r = nghttp2_submit_request(client->session, config.pri,
nv.get(), req->data_prd, req); nv.get(), req->data_prd, req);
assert(r == 0); assert(r == 0);
} }
...@@ -1411,7 +1413,8 @@ int run(char **uris, int n) ...@@ -1411,7 +1413,8 @@ int run(char **uris, int n)
void print_usage(std::ostream& out) void print_usage(std::ostream& out)
{ {
out << "Usage: nghttp [-FOafnsuv] [-t <SECONDS>] [-w <WINDOW_BITS>] [--cert=<CERT>]\n" out << "Usage: nghttp [-FOafnsuv] [-t <SECONDS>] [-w <WINDOW_BITS>] [--cert=<CERT>]\n"
<< " [--key=<KEY>] [--no-tls] [-d <FILE>] [-m <N>] <URI>..." << " [--key=<KEY>] [--no-tls] [-d <FILE>] [-m <N>] [-p <PRIORITY>]\n"
<< " <URI>..."
<< std::endl; << std::endl;
} }
...@@ -1455,6 +1458,9 @@ void print_help(std::ostream& out) ...@@ -1455,6 +1458,9 @@ void print_help(std::ostream& out)
<< " option is ignored if --no-tls is not given.\n" << " option is ignored if --no-tls is not given.\n"
<< " If -d is used, the HTTP upgrade request is\n" << " If -d is used, the HTTP upgrade request is\n"
<< " performed with OPTIONS method.\n" << " performed with OPTIONS method.\n"
<< " -p, --pri=<PRIORITY>\n"
<< " Sets stream priority. Default: "
<< NGHTTP2_PRI_DEFAULT << "\n"
<< std::endl; << std::endl;
} }
...@@ -1480,10 +1486,11 @@ int main(int argc, char **argv) ...@@ -1480,10 +1486,11 @@ int main(int argc, char **argv)
{"no-connection-flow-control", no_argument, 0, 'F'}, {"no-connection-flow-control", no_argument, 0, 'F'},
{"no-stream-flow-control", no_argument, 0, 'f'}, {"no-stream-flow-control", no_argument, 0, 'f'},
{"upgrade", no_argument, 0, 'u'}, {"upgrade", no_argument, 0, 'u'},
{"pri", required_argument, 0, 'p'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
int option_index = 0; int option_index = 0;
int c = getopt_long(argc, argv, "FOad:fm:nhH:vst:uw:", long_options, int c = getopt_long(argc, argv, "FOad:fm:np:hH:vst:uw:", long_options,
&option_index); &option_index);
if(c == -1) { if(c == -1) {
break; break;
...@@ -1504,6 +1511,18 @@ int main(int argc, char **argv) ...@@ -1504,6 +1511,18 @@ int main(int argc, char **argv)
case 'n': case 'n':
config.null_out = true; config.null_out = true;
break; break;
case 'p': {
auto n = strtoul(optarg, nullptr, 10);
if(n <= NGHTTP2_PRI_LOWEST) {
config.pri = n;
} else {
std::cerr << "-p: specify the integer in the range [0, "
<< NGHTTP2_PRI_LOWEST << "], inclusive"
<< std::endl;
exit(EXIT_FAILURE);
}
break;
}
case 'v': case 'v':
config.verbose = true; config.verbose = true;
break; break;
......
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