Commit 1fca42ed authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Remove :version from http2 connection

parent 5ccf647d
...@@ -720,7 +720,6 @@ int Http2Upstream::error_reply(Downstream *downstream, int status_code) ...@@ -720,7 +720,6 @@ int Http2Upstream::error_reply(Downstream *downstream, int status_code)
const char *nv[] = { const char *nv[] = {
":status", http::get_status_string(status_code), ":status", http::get_status_string(status_code),
":version", "http/1.1",
"content-type", "text/html; charset=UTF-8", "content-type", "text/html; charset=UTF-8",
"server", get_config()->server_name, "server", get_config()->server_name,
"content-length", content_length.c_str(), "content-length", content_length.c_str(),
...@@ -784,14 +783,12 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) ...@@ -784,14 +783,12 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream)
DLOG(INFO, downstream) << "HTTP response header completed"; DLOG(INFO, downstream) << "HTTP response header completed";
} }
size_t nheader = downstream->get_response_headers().size(); size_t nheader = downstream->get_response_headers().size();
// 6 means :status, :version and possible via header field. // 4 means :status and possible via header field.
const char **nv = new const char*[nheader * 2 + 6 + 1]; const char **nv = new const char*[nheader * 2 + 4 + 1];
size_t hdidx = 0; size_t hdidx = 0;
std::string via_value; std::string via_value;
nv[hdidx++] = ":status"; nv[hdidx++] = ":status";
nv[hdidx++] = http::get_status_string(downstream->get_response_http_status()); nv[hdidx++] = http::get_status_string(downstream->get_response_http_status());
nv[hdidx++] = ":version";
nv[hdidx++] = "HTTP/1.1";
for(Headers::const_iterator i = downstream->get_response_headers().begin(); for(Headers::const_iterator i = downstream->get_response_headers().begin();
i != downstream->get_response_headers().end(); ++i) { i != downstream->get_response_headers().end(); ++i) {
if(util::strieq((*i).first.c_str(), "transfer-encoding") || if(util::strieq((*i).first.c_str(), "transfer-encoding") ||
......
...@@ -745,24 +745,13 @@ void on_frame_recv_callback ...@@ -745,24 +745,13 @@ void on_frame_recv_callback
break; break;
} }
auto nva = frame->headers.nva; auto nva = frame->headers.nva;
std::string status, version, content_length; std::string status, content_length;
for(size_t i = 0; i < frame->headers.nvlen; ++i) { for(size_t i = 0; i < frame->headers.nvlen; ++i) {
if(util::strieq(":status", nva[i].name, nva[i].namelen)) { if(util::strieq(":status", nva[i].name, nva[i].namelen)) {
status.assign(reinterpret_cast<char*>(nva[i].value), status.assign(reinterpret_cast<char*>(nva[i].value),
nva[i].valuelen); nva[i].valuelen);
auto code = strtoul(status.c_str(), nullptr, 10); auto code = strtoul(status.c_str(), nullptr, 10);
downstream->set_response_http_status(code); downstream->set_response_http_status(code);
} else if(util::strieq(":version", nva[i].name, nva[i].namelen)) {
// We assume for now that most version is HTTP/1.1 from
// SPDY. So just check if it is HTTP/1.0 and then set response
// minor as so.
downstream->set_response_major(1);
version.assign(reinterpret_cast<char*>(nva[i].value), nva[i].valuelen);
if(util::strieq("HTTP/1.0", version.c_str())) {
downstream->set_response_minor(0);
} else {
downstream->set_response_minor(1);
}
} else if(nva[i].namelen > 0 && nva[i].name[0] != ':') { } else if(nva[i].namelen > 0 && nva[i].name[0] != ':') {
if(util::strieq("content-length", nva[i].name, nva[i].namelen)) { if(util::strieq("content-length", nva[i].name, nva[i].namelen)) {
content_length.assign(reinterpret_cast<char*>(nva[i].value), content_length.assign(reinterpret_cast<char*>(nva[i].value),
...@@ -775,11 +764,11 @@ void on_frame_recv_callback ...@@ -775,11 +764,11 @@ void on_frame_recv_callback
nva[i].valuelen)); nva[i].valuelen));
} }
} }
if(version.empty()) { // Just assume it is HTTP/1.1. But we really consider to say 2.0
// If no version, just assume it is HTTP/1.1 // here.
downstream->set_response_major(1); downstream->set_response_major(1);
downstream->set_response_minor(1); downstream->set_response_minor(1);
}
if(status.empty()) { if(status.empty()) {
nghttp2_submit_rst_stream(session, frame->hd.stream_id, nghttp2_submit_rst_stream(session, frame->hd.stream_id,
NGHTTP2_PROTOCOL_ERROR); NGHTTP2_PROTOCOL_ERROR);
......
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