shrpx: Check request_connection_close_ when deciding closing connection
When deciding whether to close the client connection, check request_connection_close_ of Downstream in addition of response_connection_close_. Also we only add "Connection: Keep-Alive" header to the HTTP/1.0 or HTTP/0.9 clients.
This commit is contained in:
parent
22516aea63
commit
436b201d6f
|
@ -579,15 +579,18 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(downstream->get_response_version() < 101) {
|
// We check downstream->get_response_connection_close() in case when
|
||||||
if(!downstream->get_response_connection_close()) {
|
// the Content-Length is not available.
|
||||||
|
if(!downstream->get_request_connection_close() &&
|
||||||
|
!downstream->get_response_connection_close()) {
|
||||||
|
if(downstream->get_request_major() <= 0 ||
|
||||||
|
downstream->get_request_minor() <= 0) {
|
||||||
|
// We add this header for HTTP/1.0 or HTTP/0.9 clients
|
||||||
hdrs += "Connection: Keep-Alive\r\n";
|
hdrs += "Connection: Keep-Alive\r\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(downstream->get_response_connection_close()) {
|
|
||||||
hdrs += "Connection: close\r\n";
|
hdrs += "Connection: close\r\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
hdrs += "Via: ";
|
hdrs += "Via: ";
|
||||||
hdrs += via_value;
|
hdrs += via_value;
|
||||||
|
@ -642,7 +645,8 @@ int HttpsUpstream::on_downstream_body_complete(Downstream *downstream)
|
||||||
if(ENABLE_LOG) {
|
if(ENABLE_LOG) {
|
||||||
LOG(INFO) << "Downstream on_downstream_body_complete";
|
LOG(INFO) << "Downstream on_downstream_body_complete";
|
||||||
}
|
}
|
||||||
if(downstream->get_response_connection_close()) {
|
if(downstream->get_request_connection_close() ||
|
||||||
|
downstream->get_response_connection_close()) {
|
||||||
ClientHandler *handler = get_client_handler();
|
ClientHandler *handler = get_client_handler();
|
||||||
handler->set_should_close_after_write(true);
|
handler->set_should_close_after_write(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue