nghttpx: Preserve upgrade in Connection header field

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-02 00:00:33 +09:00
parent 8fd1953b21
commit 5594f0ef0b
1 changed files with 7 additions and 4 deletions

View File

@ -118,7 +118,7 @@ int HttpDownstreamConnection::push_request_headers()
hdrs += downstream_->get_request_path(); hdrs += downstream_->get_request_path();
hdrs += " "; hdrs += " ";
hdrs += "HTTP/1.1\r\n"; hdrs += "HTTP/1.1\r\n";
bool connection_upgrade = false; std::string connection_upgrade;
std::string via_value; std::string via_value;
std::string xff_value; std::string xff_value;
const Headers& request_headers = downstream_->get_request_headers(); const Headers& request_headers = downstream_->get_request_headers();
@ -126,8 +126,9 @@ int HttpDownstreamConnection::push_request_headers()
i != request_headers.end(); ++i) { i != request_headers.end(); ++i) {
if(util::strieq((*i).first.c_str(), "connection")) { if(util::strieq((*i).first.c_str(), "connection")) {
if(util::strifind((*i).second.c_str(), "upgrade")) { 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") || } 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(), "keep-alive") ||
util::strieq((*i).first.c_str(), "proxy-connection")) { util::strieq((*i).first.c_str(), "proxy-connection")) {
@ -153,8 +154,10 @@ int HttpDownstreamConnection::push_request_headers()
} }
if(downstream_->get_request_connection_close()) { if(downstream_->get_request_connection_close()) {
hdrs += "Connection: close\r\n"; hdrs += "Connection: close\r\n";
} else if(connection_upgrade) { } else if(!connection_upgrade.empty()) {
hdrs += "Connection: upgrade\r\n"; hdrs += "Connection: ";
hdrs += connection_upgrade;
hdrs += "\r\n";
} }
if(get_config()->add_x_forwarded_for) { if(get_config()->add_x_forwarded_for) {
hdrs += "X-Forwarded-For: "; hdrs += "X-Forwarded-For: ";