From 5594f0ef0bf3a0c524ecc53376f8db4bc0e91358 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 2 Aug 2013 00:00:33 +0900 Subject: [PATCH] nghttpx: Preserve upgrade in Connection header field --- src/shrpx_http_downstream_connection.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index b86efced..f9cd8690 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -118,7 +118,7 @@ int HttpDownstreamConnection::push_request_headers() hdrs += downstream_->get_request_path(); hdrs += " "; hdrs += "HTTP/1.1\r\n"; - bool connection_upgrade = false; + std::string connection_upgrade; std::string via_value; std::string xff_value; const Headers& request_headers = downstream_->get_request_headers(); @@ -126,8 +126,9 @@ int HttpDownstreamConnection::push_request_headers() i != request_headers.end(); ++i) { if(util::strieq((*i).first.c_str(), "connection")) { if(util::strifind((*i).second.c_str(), "upgrade")) { - connection_upgrade = true; + connection_upgrade = (*i).second; } + continue; } else if(util::strieq((*i).first.c_str(), "x-forwarded-proto") || util::strieq((*i).first.c_str(), "keep-alive") || util::strieq((*i).first.c_str(), "proxy-connection")) { @@ -153,8 +154,10 @@ int HttpDownstreamConnection::push_request_headers() } if(downstream_->get_request_connection_close()) { hdrs += "Connection: close\r\n"; - } else if(connection_upgrade) { - hdrs += "Connection: upgrade\r\n"; + } else if(!connection_upgrade.empty()) { + hdrs += "Connection: "; + hdrs += connection_upgrade; + hdrs += "\r\n"; } if(get_config()->add_x_forwarded_for) { hdrs += "X-Forwarded-For: ";