From b6d88f39aceda2e093e1bf8751f07236b7d9e483 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 12 Jan 2016 15:18:12 +0100 Subject: Only enable pipelining if server is HTTP/1.1 Just enabling it for anyone breaks with HTTP/1.0 servers and proxies sometimes. Closes: #810796 --- methods/server.cc | 8 ++++++++ methods/server.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/server.cc b/methods/server.cc index d5188d4a3..6340390d4 100644 --- a/methods/server.cc +++ b/methods/server.cc @@ -150,9 +150,15 @@ bool ServerState::HeaderLine(string Line) else { if (Major == 1 && Minor == 0) + { Persistent = false; + } else + { Persistent = true; + if (PipelineAllowed) + Pipeline = true; + } } return true; @@ -532,6 +538,7 @@ int ServerMethod::Loop() _error->Discard(); Server->Close(); Server->Pipeline = false; + Server->PipelineAllowed = false; if (FailCounter >= 2) { @@ -604,6 +611,7 @@ int ServerMethod::Loop() strprintf(out, _("Automatically disabled %s due to incorrect response from server/proxy. (man 5 apt.conf)"), "Acquire::http::PipelineDepth"); std::cerr << "W: " << out << std::endl; Server->Pipeline = false; + Server->PipelineAllowed = false; // we keep the PipelineDepth value so that the rest of the queue can be fixed up as well } Rename(Res.Filename, I->DestFile); diff --git a/methods/server.h b/methods/server.h index 365bc0879..3f6502432 100644 --- a/methods/server.h +++ b/methods/server.h @@ -51,6 +51,7 @@ struct ServerState enum {Chunked,Stream,Closes} Encoding; enum {Header, Data} State; bool Persistent; + bool PipelineAllowed; std::string Location; // This is a Persistent attribute of the server itself. @@ -86,7 +87,7 @@ struct ServerState bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;}; virtual void Reset() {Major = 0; Minor = 0; Result = 0; Code[0] = '\0'; TotalFileSize = 0; JunkSize = 0; StartPos = 0; Encoding = Closes; time(&Date); HaveContent = false; - State = Header; Persistent = false; Pipeline = true; MaximumSize = 0;}; + State = Header; Persistent = false; Pipeline = false; MaximumSize = 0; PipelineAllowed = true;}; virtual bool WriteResponse(std::string const &Data) = 0; /** \brief Transfer the data from the socket */ -- cgit v1.2.3