From 6958d0b55d30728efcc92baa83e643f66078759b Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 7 Nov 2015 11:14:28 +0900 Subject: [PATCH] nghttp: Use method given in -H with ":method" in HTTP Upgrade --- src/nghttp.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/nghttp.cc b/src/nghttp.cc index 2d14367a..cf0bef2b 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -813,7 +813,16 @@ int HttpClient::on_upgrade_connect() { // If the request contains upload data, use OPTIONS * to upgrade req = "OPTIONS *"; } else { - req = "GET "; + auto meth = std::find_if( + std::begin(config.headers), std::end(config.headers), + [](const Header &kv) { return util::strieq_l(":method", kv.name); }); + + if (meth == std::end(config.headers)) { + req = "GET "; + } else { + req = (*meth).value; + req += " "; + } req += reqvec[0]->make_reqpath(); }