diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 5a15e86a..b4e5ee2f 100644 --- a/src/AbstractCommand.cc +++ b/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())); diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index f5072dc6..bb03659d 100644 --- a/src/HttpResponseCommand.cc +++ b/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();