nghttp: Fix -H does not work with -u upgrade request
This commit is contained in:
parent
b371331297
commit
512aa8942a
|
@ -789,18 +789,38 @@ int HttpClient::on_upgrade_connect() {
|
||||||
req = "GET ";
|
req = "GET ";
|
||||||
req += reqvec[0]->make_reqpath();
|
req += reqvec[0]->make_reqpath();
|
||||||
}
|
}
|
||||||
req += " HTTP/1.1\r\n"
|
|
||||||
"Host: ";
|
auto headers = Headers{{"Host", hostport},
|
||||||
req += hostport;
|
{"Connection", "Upgrade, HTTP2-Settings"},
|
||||||
req += "\r\n"
|
{"Upgrade", NGHTTP2_CLEARTEXT_PROTO_VERSION_ID},
|
||||||
"Connection: Upgrade, HTTP2-Settings\r\n"
|
{"HTTP2-Settings", token68},
|
||||||
"Upgrade: " NGHTTP2_CLEARTEXT_PROTO_VERSION_ID "\r\n"
|
{"Accept", "*/*"},
|
||||||
"HTTP2-Settings: ";
|
{"User-Agent", "nghttp2/" NGHTTP2_VERSION}};
|
||||||
req += token68;
|
auto initial_headerslen = headers.size();
|
||||||
req += "\r\n"
|
|
||||||
"Accept: */*\r\n"
|
for (auto &kv : config.headers) {
|
||||||
"User-Agent: nghttp2/" NGHTTP2_VERSION "\r\n"
|
size_t i;
|
||||||
"\r\n";
|
for (i = 0; i < initial_headerslen; ++i) {
|
||||||
|
if (util::strieq(kv.name, headers[i].name)) {
|
||||||
|
headers[i].value = kv.value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i < initial_headerslen) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
headers.emplace_back(kv.name, kv.value, kv.no_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
req += " HTTP/1.1\r\n";
|
||||||
|
|
||||||
|
for (auto &kv : headers) {
|
||||||
|
req += kv.name;
|
||||||
|
req += ": ";
|
||||||
|
req += kv.value;
|
||||||
|
req += "\r\n";
|
||||||
|
}
|
||||||
|
req += "\r\n";
|
||||||
|
|
||||||
wb.write(req.c_str(), req.size());
|
wb.write(req.c_str(), req.size());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue