X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/3f506f684c6199a9a2bc68365732a9c00dc551c1..baec76f5f0f9fcbd71f6e2afaa7fc85543bd624c:/methods/http.h diff --git a/methods/http.h b/methods/http.h index 02c04e8ae..b7341f5f8 100644 --- a/methods/http.h +++ b/methods/http.h @@ -3,7 +3,7 @@ // $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $ /* ###################################################################### - HTTP Acquire Method - This is the HTTP aquire method for APT. + HTTP Acquire Method - This is the HTTP acquire method for APT. ##################################################################### */ /*}}}*/ @@ -14,12 +14,15 @@ #include #include +#include +#include #include "server.h" using std::cout; using std::endl; +class FileFd; class HttpMethod; class Hashes; @@ -59,10 +62,12 @@ class CircleBuf public: Hashes *Hash; + // total amount of data that got written so far + unsigned long long TotalWriten; // Read data in bool Read(int Fd); - bool Read(std::string Data); + bool Read(std::string const &Data); // Write data out bool Write(int Fd); @@ -77,11 +82,11 @@ class CircleBuf bool ReadSpace() const {return Size - (InP - OutP) > 0;}; bool WriteSpace() const {return InP - OutP > 0;}; - // Dump everything void Reset(); + // Dump everything void Stats(); - CircleBuf(unsigned long long Size); + CircleBuf(HttpMethod const * const Owner, unsigned long long Size); ~CircleBuf(); }; @@ -93,23 +98,24 @@ struct HttpServerState: public ServerState int ServerFd; protected: - virtual bool ReadHeaderLines(std::string &Data); - virtual bool LoadNextResponse(bool const ToFile, FileFd * const File); - virtual bool WriteResponse(std::string const &Data); + virtual bool ReadHeaderLines(std::string &Data) APT_OVERRIDE; + virtual bool LoadNextResponse(bool const ToFile, FileFd * const File) APT_OVERRIDE; + virtual bool WriteResponse(std::string const &Data) APT_OVERRIDE; public: - virtual void Reset() { ServerState::Reset(); ServerFd = -1; }; + virtual void Reset(bool const Everything = true) APT_OVERRIDE; - virtual bool RunData(FileFd * const File); + virtual bool RunData(FileFd * const File) APT_OVERRIDE; + virtual bool RunDataToDevNull() APT_OVERRIDE; - virtual bool Open(); - virtual bool IsOpen(); - virtual bool Close(); - virtual bool InitHashes(FileFd &File); - virtual Hashes * GetHashes(); - virtual bool Die(FileFd &File); - virtual bool Flush(FileFd * const File); - virtual bool Go(bool ToFile, FileFd * const File); + 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 Flush(FileFd * const File) APT_OVERRIDE; + virtual bool Go(bool ToFile, FileFd * const File) APT_OVERRIDE; HttpServerState(URI Srv, HttpMethod *Owner); virtual ~HttpServerState() {Close();}; @@ -118,15 +124,11 @@ struct HttpServerState: public ServerState class HttpMethod : public ServerMethod { public: - virtual void SendReq(FetchItem *Itm); - - /** \brief Try to AutoDetect the proxy */ - bool AutoDetectProxy(); + virtual void SendReq(FetchItem *Itm) APT_OVERRIDE; - virtual bool Configuration(std::string Message); - - virtual ServerState * CreateServerState(URI uri); - virtual void RotateDNS(); + virtual std::unique_ptr CreateServerState(URI const &uri) APT_OVERRIDE; + virtual void RotateDNS() APT_OVERRIDE; + virtual DealWithHeadersResult DealWithHeaders(FetchResult &Res) APT_OVERRIDE; protected: std::string AutoDetectProxyCmd; @@ -134,11 +136,7 @@ class HttpMethod : public ServerMethod public: friend struct HttpServerState; - HttpMethod() : ServerMethod("1.2",Pipeline | SendConfig) - { - File = 0; - Server = 0; - }; + explicit HttpMethod(std::string &&pProg); }; #endif