From 7f51a104d161e5d4e9fe0c43d0cd94cafd13e248 Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Sat, 17 Aug 2019 20:00:42 -1000 Subject: Cleanup patches for 1.8.2 --- methods/connect.cc | 4 ++-- methods/http.cc | 32 ++++++++++---------------------- methods/http.h | 1 + 3 files changed, 13 insertions(+), 24 deletions(-) (limited to 'methods') diff --git a/methods/connect.cc b/methods/connect.cc index 1d6f8919d..0e01e5ca4 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -273,8 +273,8 @@ static ResultState WaitAndCheckErrors(std::list &Conns, std::unique_ struct timeval tv = { // Split our millisecond timeout into seconds and microseconds - .tv_sec = TimeoutMsec / 1000, - .tv_usec = (TimeoutMsec % 1000) * 1000, + .tv_sec = static_cast(TimeoutMsec / 1000), + .tv_usec = static_cast((TimeoutMsec % 1000) * 1000), }; // We will return once we have no more connections, a time out, or diff --git a/methods/http.cc b/methods/http.cc index 647b35c6b..16c0de611 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -164,32 +164,28 @@ void HttpMethod::RotateDNS() /*{{{*/ { } /*}}}*/ -BaseHttpMethod::DealWithHeadersResult HttpMethod::DealWithHeaders(FetchResult &Res)/*{{{*/ +BaseHttpMethod::DealWithHeadersResult HttpMethod::DealWithHeaders(FetchResult &Res, RequestState &Req)/*{{{*/ { - auto ret = BaseHttpMethod::DealWithHeaders(Res); + auto ret = BaseHttpMethod::DealWithHeaders(Res, Req); if (ret != BaseHttpMethod::FILE_IS_OPEN) return ret; - - // Open the file - delete File; - File = new FileFd(Queue->DestFile,FileFd::WriteAny); - if (_error->PendingError() == true) + if (Req.File.Open(Queue->DestFile, FileFd::WriteAny) == false) return ERROR_NOT_FROM_SERVER; FailFile = Queue->DestFile; FailFile.c_str(); // Make sure we don't do a malloc in the signal handler - FailFd = File->Fd(); - FailTime = Server->Date; + FailFd = Req.File.Fd(); + FailTime = Req.Date; - if (Server->InitHashes(Queue->ExpectedHashes) == false || Server->AddPartialFileToHashes(*File) == false) + if (Server->InitHashes(Queue->ExpectedHashes) == false || Req.AddPartialFileToHashes(Req.File) == false) { _error->Errno("read",_("Problem hashing file")); return ERROR_NOT_FROM_SERVER; } - if (Server->StartPos > 0) - Res.ResumePoint = Server->StartPos; + if (Req.StartPos > 0) + Res.ResumePoint = Req.StartPos; - SetNonBlock(File->Fd(),true); + SetNonBlock(Req.File.Fd(),true); return FILE_IS_OPEN; } @@ -544,22 +540,14 @@ int HttpMethod::Loop() return 0; } - /*}}}*/ HttpMethod::HttpMethod(std::string &&pProg) : BaseHttpMethod(pProg.c_str(), "1.2", Pipeline | SendConfig)/*{{{*/ { - SeccompFlags = aptMethod::BASE | aptMethod::NETWORK; - auto addName = std::inserter(methodNames, methodNames.begin()); - if (Binary != "http") + if (Binary != "http" && Binary != "https") addName = "http"; auto const plus = Binary.find('+'); if (plus != std::string::npos) - { - auto name2 = Binary.substr(plus + 1); - if (std::find(methodNames.begin(), methodNames.end(), name2) == methodNames.end()) - addName = std::move(name2); addName = Binary.substr(0, plus); - } File = 0; Server = 0; } diff --git a/methods/http.h b/methods/http.h index f52aa8a1f..15691379d 100644 --- a/methods/http.h +++ b/methods/http.h @@ -38,6 +38,7 @@ class HttpMethod : public BaseHttpMethod virtual DealWithHeadersResult DealWithHeaders(FetchResult &Res, RequestState &Req) APT_OVERRIDE; protected: + FileFd *File; std::string AutoDetectProxyCmd; public: -- cgit v1.2.3