1
0
mirror of https://github.com/moparisthebest/spdylay synced 2024-12-22 15:48:53 -05:00

Send back Connection: keep-alive for the request with http/1.0 keep-alive

This commit is contained in:
Tatsuhiro Tsujikawa 2012-06-07 22:40:42 +09:00
parent 7319620160
commit 9303cca430
3 changed files with 17 additions and 0 deletions

View File

@ -116,6 +116,8 @@ void check_request_connection(bool *connection_close,
if(util::strieq(item.first.c_str(), "connection")) {
if(util::strifind(item.second.c_str(), "close")) {
*connection_close = true;
} else if(util::strifind(item.second.c_str(), "keep-alive")) {
*connection_close = false;
}
}
}
@ -155,6 +157,16 @@ void Downstream::set_request_minor(int minor)
request_minor_ = minor;
}
int Downstream::get_request_major() const
{
return request_major_;
}
int Downstream::get_request_minor() const
{
return request_minor_;
}
Upstream* Downstream::get_upstream() const
{
return upstream_;

View File

@ -65,6 +65,8 @@ public:
void set_request_path(const std::string& path);
void set_request_major(int major);
void set_request_minor(int minor);
int get_request_major() const;
int get_request_minor() const;
int push_request_headers();
bool get_chunked_request() const;
bool get_request_connection_close() const;

View File

@ -476,6 +476,9 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream)
}
if(get_client_handler()->get_should_close_after_write()) {
hdrs += "Connection: close\r\n";
} else if(downstream->get_request_major() == 1 &&
downstream->get_request_minor() == 0) {
hdrs += "Connection: Keep-Alive\r\n";
}
hdrs += "Via: ";
hdrs += via_value;