Przeglądaj źródła

Handle the situation when remote server returns Connection: close
after several pipelined requests.

We call Request::setMaxPipelinedRequest(1) if Connection: close is
received. Also call Request::supportsPersistentConnection(true) and
Request::setMaxPipelinedRequest(1) when closing the connection.

Tatsuhiro Tsujikawa 14 lat temu
rodzic
commit
63fe7874da
2 zmienionych plików z 8 dodań i 0 usunięć
  1. 6 0
      src/AbstractCommand.cc
  2. 2 0
      src/HttpResponseCommand.cc

+ 6 - 0
src/AbstractCommand.cc

@@ -347,6 +347,12 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
     getSegmentMan()->cancelSegment(getCuid());
   }
   if(req_) {
+    // Reset persistentConnection and maxPipelinedRequest to handle
+    // the situation where remote server returns Connection: close
+    // after several pipelined requests.
+    req_->supportsPersistentConnection(true);
+    req_->setMaxPipelinedRequest(1);
+
     fileEntry_->poolRequest(req_);
     A2_LOG_DEBUG(fmt("CUID#%lld - Pooling request URI=%s",
                      getCuid(), req_->getUri().c_str()));

+ 2 - 0
src/HttpResponseCommand.cc

@@ -169,6 +169,8 @@ bool HttpResponseCommand::executeInternal()
   if(getRequest()->isPipeliningEnabled()) {
     getRequest()->setMaxPipelinedRequest
       (getOption()->getAsInt(PREF_MAX_HTTP_PIPELINING));
+  } else {
+    getRequest()->setMaxPipelinedRequest(1);
   }
 
   int statusCode = httpResponse->getStatusCode();