From 13a9f08de18dea0dfc1951992b0ddeda9c2fa2dd Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 9 Nov 2016 12:25:44 +0100 Subject: separating state variables regarding server/request Having a Reset(bool) method to partially reset certain variables like the download size always were strange, so this commit splits the ServerState into an additional RequestState living on the stack for as long as we deal with this request causing an automatic "reset". There is much to do still to make this code look better, but this is a good first step which compiles cleanly and passes all tests, so keeping it as history might be beneficial and due to avoiding explicit memory allocations it ends up fixing a small memory leak in https, too. Closes: #440057 --- methods/http.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'methods/http.h') diff --git a/methods/http.h b/methods/http.h index b7341f5f8..4b0e77524 100644 --- a/methods/http.h +++ b/methods/http.h @@ -99,23 +99,23 @@ struct HttpServerState: public ServerState protected: virtual bool ReadHeaderLines(std::string &Data) APT_OVERRIDE; - virtual bool LoadNextResponse(bool const ToFile, FileFd * const File) APT_OVERRIDE; + virtual bool LoadNextResponse(bool const ToFile, RequestState &Req) APT_OVERRIDE; virtual bool WriteResponse(std::string const &Data) APT_OVERRIDE; public: - virtual void Reset(bool const Everything = true) APT_OVERRIDE; + virtual void Reset() APT_OVERRIDE; - virtual bool RunData(FileFd * const File) APT_OVERRIDE; - virtual bool RunDataToDevNull() APT_OVERRIDE; + virtual bool RunData(RequestState &Req) APT_OVERRIDE; + virtual bool RunDataToDevNull(RequestState &Req) APT_OVERRIDE; virtual bool Open() APT_OVERRIDE; virtual bool IsOpen() APT_OVERRIDE; virtual bool Close() APT_OVERRIDE; virtual bool InitHashes(HashStringList const &ExpectedHashes) APT_OVERRIDE; virtual Hashes * GetHashes() APT_OVERRIDE; - virtual bool Die(FileFd * const File) APT_OVERRIDE; + virtual bool Die(RequestState &Req) APT_OVERRIDE; virtual bool Flush(FileFd * const File) APT_OVERRIDE; - virtual bool Go(bool ToFile, FileFd * const File) APT_OVERRIDE; + virtual bool Go(bool ToFile, RequestState &Req) APT_OVERRIDE; HttpServerState(URI Srv, HttpMethod *Owner); virtual ~HttpServerState() {Close();}; @@ -128,7 +128,7 @@ class HttpMethod : public ServerMethod virtual std::unique_ptr CreateServerState(URI const &uri) APT_OVERRIDE; virtual void RotateDNS() APT_OVERRIDE; - virtual DealWithHeadersResult DealWithHeaders(FetchResult &Res) APT_OVERRIDE; + virtual DealWithHeadersResult DealWithHeaders(FetchResult &Res, RequestState &Req) APT_OVERRIDE; protected: std::string AutoDetectProxyCmd; -- cgit v1.2.3