Improve Debug::Acquire::http debug output
[ntk/apt.git] / methods / server.h
index 2d43b33..f5e68d9 100644 (file)
 #define APT_SERVER_H
 
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/acquire-method.h>
 
+#include <time.h>
+#include <iostream>
 #include <string>
 
 using std::cout;
@@ -32,7 +35,7 @@ struct ServerState
 
    // These are some statistics from the last parsed header lines
    unsigned long long Size;
-   signed long long StartPos;
+   unsigned long long StartPos;
    time_t Date;
    bool HaveContent;
    enum {Chunked,Stream,Closes} Encoding;
@@ -49,11 +52,12 @@ struct ServerState
    protected:
    ServerMethod *Owner;
 
-   bool HeaderLine(std::string Line);
    virtual bool ReadHeaderLines(std::string &Data) = 0;
    virtual bool LoadNextResponse(bool const ToFile, FileFd * const File) = 0;
 
    public:
+   bool HeaderLine(std::string Line);
+
    /** \brief Result of the header acquire */
    enum RunHeadersResult {
       /** \brief Header ok */
@@ -61,10 +65,10 @@ struct ServerState
       /** \brief IO error while retrieving */
       RUN_HEADERS_IO_ERROR,
       /** \brief Parse error after retrieving */
-      RUN_HEADERS_PARSE_ERROR,
+      RUN_HEADERS_PARSE_ERROR
    };
    /** \brief Get the headers before the data */
-   RunHeadersResult RunHeaders(FileFd * const File);
+   RunHeadersResult RunHeaders(FileFd * const File, const std::string &Uri);
 
    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'; Size = 0;
@@ -125,7 +129,7 @@ class ServerMethod : public pkgAcqMethod
    static std::string FailFile;
    static int FailFd;
    static time_t FailTime;
-   static void SigTerm(int);
+   static APT_NORETURN void SigTerm(int);
 
    virtual bool Configuration(std::string Message);
    virtual bool Flush() { return Server->Flush(File); };
@@ -134,8 +138,9 @@ class ServerMethod : public pkgAcqMethod
 
    virtual void SendReq(FetchItem *Itm) = 0;
    virtual ServerState * CreateServerState(URI uri) = 0;
+   virtual void RotateDNS() = 0;
 
-   ServerMethod(const char *Ver,unsigned long Flags = 0) : pkgAcqMethod(Ver, Flags), PipelineDepth(0), AllowRedirect(false), Debug(false) {};
+   ServerMethod(const char *Ver,unsigned long Flags = 0) : pkgAcqMethod(Ver, Flags), Server(NULL), File(NULL), PipelineDepth(0), AllowRedirect(false), Debug(false) {};
    virtual ~ServerMethod() {};
 };