Browse Source

2008-05-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Disable http keep-alive if the remote server is not HTTP/1.1.
	* src/HttpConnection.cc
Tatsuhiro Tsujikawa 17 years ago
parent
commit
e88eedc8f5
2 changed files with 10 additions and 2 deletions
  1. 5 0
      ChangeLog
  2. 5 2
      src/HttpConnection.cc

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-05-07  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Disable http keep-alive if the remote server is not HTTP/1.1.
+	* src/HttpConnection.cc
+
 2008-05-07  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Receive content body of 302 response so that the connection can be

+ 5 - 2
src/HttpConnection.cc

@@ -134,9 +134,12 @@ HttpResponseHandle HttpConnection::receiveResponse()
 
   // OK, we got all headers.
   logger->info(MSG_RECEIVE_RESPONSE, cuid, proc->getHeaderString().c_str());
-
+  // Disable persistent connection if:
+  //   Connection: close is received or the remote server is not HTTP/1.1.
+  // We don't care whether non-HTTP/1.1 server returns Connection: keep-alive.
   SharedHandle<HttpHeader> httpHeader = proc->getHttpResponseHeader();
-  if(Util::toLower(httpHeader->getFirst("Connection")).find("close") != std::string::npos) {
+  if(Util::toLower(httpHeader->getFirst("Connection")).find("close") != std::string::npos
+     || httpHeader->getVersion() != "HTTP/1.1") {
     entry->getHttpRequest()->getRequest()->supportsPersistentConnection(false);
   } else {
     entry->getHttpRequest()->getRequest()->supportsPersistentConnection(true);