From 61c1d7d3658fdcd4b32f8b071cef7941120f8abc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 16 Sep 2021 19:33:24 +0200 Subject: Add AllowRange option to disable HTTP Range usage apt makes heavy usage of HTTP1.1 features including Range and If-Range. Sadly it is not obvious if the involved server(s) (and proxies) actually support them all. The Acquire::http::AllowRange option defaults to true as before, but now a user can disable Range usage if it is known that the involved server is not dealing with such requests correctly. --- methods/basehttp.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'methods') diff --git a/methods/basehttp.cc b/methods/basehttp.cc index f2c4156e1..396b33999 100644 --- a/methods/basehttp.cc +++ b/methods/basehttp.cc @@ -246,7 +246,7 @@ bool RequestState::HeaderLine(string const &Line) /*{{{*/ return true; } - if (stringcasecmp(Tag, "Accept-Ranges:") == 0) + if (Server->RangesAllowed && stringcasecmp(Tag, "Accept-Ranges:") == 0) { std::string ranges = ',' + Val + ','; ranges.erase(std::remove(ranges.begin(), ranges.end(), ' '), ranges.end()); @@ -276,7 +276,6 @@ void ServerState::Reset() /*{{{*/ Persistent = false; Pipeline = false; PipelineAllowed = true; - RangesAllowed = true; PipelineAnswersReceived = 0; } /*}}}*/ @@ -607,6 +606,7 @@ int BaseHttpMethod::Loop() setPostfixForMethodNames(::URI(Queue->Uri).Host.c_str()); AllowRedirect = ConfigFindB("AllowRedirect", true); PipelineDepth = ConfigFindI("Pipeline-Depth", 10); + Server->RangesAllowed = ConfigFindB("AllowRanges", true); Debug = DebugEnabled(); } -- cgit v1.2.3-70-g09d2