]> git.saurik.com Git - apt.git/blame - methods/https.h
add c++11 override marker to overridden methods
[apt.git] / methods / https.h
CommitLineData
d546f98d
MV
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/// $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
3// $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
4/* ######################################################################
5
1e3f4083 6 HTTP Acquire Method - This is the HTTP acquire method for APT.
d546f98d
MV
7
8 ##################################################################### */
9 /*}}}*/
10
f40db111
DK
11#ifndef APT_HTTPS_H
12#define APT_HTTPS_H
d546f98d 13
453b82a3
DK
14#include <apt-pkg/acquire-method.h>
15
d546f98d 16#include <curl/curl.h>
453b82a3
DK
17#include <iostream>
18#include <stddef.h>
19#include <string>
d546f98d 20
fd46d305
DK
21#include "server.h"
22
d546f98d
MV
23using std::cout;
24using std::endl;
25
453b82a3 26class Hashes;
d546f98d 27class HttpsMethod;
472ff00e 28class FileFd;
d546f98d 29
fd46d305
DK
30class HttpsServerState : public ServerState
31{
34faa8f7
DK
32 Hashes * Hash;
33
fd46d305 34 protected:
3b302846
DK
35 virtual bool ReadHeaderLines(std::string &/*Data*/) APT_OVERRIDE { return false; }
36 virtual bool LoadNextResponse(bool const /*ToFile*/, FileFd * const /*File*/) APT_OVERRIDE { return false; }
fd46d305
DK
37
38 public:
3b302846 39 virtual bool WriteResponse(std::string const &/*Data*/) APT_OVERRIDE { return false; }
fd46d305
DK
40
41 /** \brief Transfer the data from the socket */
3b302846 42 virtual bool RunData(FileFd * const /*File*/) APT_OVERRIDE { return false; }
fd46d305 43
3b302846
DK
44 virtual bool Open() APT_OVERRIDE { return false; }
45 virtual bool IsOpen() APT_OVERRIDE { return false; }
46 virtual bool Close() APT_OVERRIDE { return false; }
47 virtual bool InitHashes(HashStringList const &ExpectedHashes) APT_OVERRIDE;
48 virtual Hashes * GetHashes() APT_OVERRIDE;
49 virtual bool Die(FileFd &/*File*/) APT_OVERRIDE { return false; }
50 virtual bool Flush(FileFd * const /*File*/) APT_OVERRIDE { return false; }
51 virtual bool Go(bool /*ToFile*/, FileFd * const /*File*/) APT_OVERRIDE { return false; }
fd46d305
DK
52
53 HttpsServerState(URI Srv, HttpsMethod *Owner);
54 virtual ~HttpsServerState() {Close();};
55};
56
905fba60 57class HttpsMethod : public ServerMethod
d546f98d 58{
5085e660
MV
59 // minimum speed in bytes/se that triggers download timeout handling
60 static const int DL_MIN_SPEED = 10;
d546f98d 61
3b302846 62 virtual bool Fetch(FetchItem *) APT_OVERRIDE;
9983999d 63
fd46d305 64 static size_t parse_header(void *buffer, size_t size, size_t nmemb, void *userp);
d546f98d 65 static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
d61960d9
DK
66 static int progress_callback(void *clientp, double dltotal, double dlnow,
67 double ultotal, double ulnow);
21fd1746 68 void SetupProxy();
d546f98d 69 CURL *curl;
905fba60
DK
70 ServerState *Server;
71
72 // Used by ServerMethods unused by https
3b302846
DK
73 virtual void SendReq(FetchItem *) APT_OVERRIDE { exit(42); }
74 virtual void RotateDNS() APT_OVERRIDE { exit(42); }
d546f98d
MV
75
76 public:
77 FileFd *File;
d61960d9 78
3b302846
DK
79 virtual bool Configuration(std::string Message) APT_OVERRIDE;
80 virtual ServerState * CreateServerState(URI uri) APT_OVERRIDE;
27925d82 81 using pkgAcqMethod::FetchResult;
dcbb364f 82 using pkgAcqMethod::FetchItem;
905fba60
DK
83
84 HttpsMethod() : ServerMethod("1.2",Pipeline | SendConfig), File(NULL)
d546f98d 85 {
d546f98d
MV
86 curl = curl_easy_init();
87 };
45a9cc46
MV
88
89 ~HttpsMethod()
90 {
91 curl_easy_cleanup(curl);
92 };
d546f98d
MV
93};
94
472ff00e 95#include <apt-pkg/strutl.h>
d546f98d
MV
96URI Proxy;
97
98#endif