]>
Commit | Line | Data |
---|---|---|
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 | ||
6 | HTTP Acquire Method - This is the HTTP acquire method for APT. | |
7 | ||
8 | ##################################################################### */ | |
9 | /*}}}*/ | |
10 | ||
11 | #ifndef APT_HTTPS_H | |
12 | #define APT_HTTPS_H | |
13 | ||
14 | #include <curl/curl.h> | |
15 | #include <iostream> | |
16 | #include <stddef.h> | |
17 | #include <string> | |
18 | #include <memory> | |
19 | ||
20 | #include "server.h" | |
21 | ||
22 | using std::cout; | |
23 | using std::endl; | |
24 | ||
25 | class Hashes; | |
26 | class HttpsMethod; | |
27 | class FileFd; | |
28 | ||
29 | class HttpsServerState : public ServerState | |
30 | { | |
31 | Hashes * Hash; | |
32 | ||
33 | protected: | |
34 | virtual bool ReadHeaderLines(std::string &/*Data*/) APT_OVERRIDE { return false; } | |
35 | virtual bool LoadNextResponse(bool const /*ToFile*/, FileFd * const /*File*/) APT_OVERRIDE { return false; } | |
36 | ||
37 | public: | |
38 | virtual bool WriteResponse(std::string const &/*Data*/) APT_OVERRIDE { return false; } | |
39 | ||
40 | /** \brief Transfer the data from the socket */ | |
41 | virtual bool RunData(FileFd * const /*File*/) APT_OVERRIDE { return false; } | |
42 | virtual bool RunDataToDevNull() APT_OVERRIDE { return false; } | |
43 | ||
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 * const /*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; } | |
52 | ||
53 | HttpsServerState(URI Srv, HttpsMethod *Owner); | |
54 | virtual ~HttpsServerState() {Close();}; | |
55 | }; | |
56 | ||
57 | class HttpsMethod : public ServerMethod | |
58 | { | |
59 | // minimum speed in bytes/se that triggers download timeout handling | |
60 | static const int DL_MIN_SPEED = 10; | |
61 | ||
62 | virtual bool Fetch(FetchItem *) APT_OVERRIDE; | |
63 | ||
64 | static size_t parse_header(void *buffer, size_t size, size_t nmemb, void *userp); | |
65 | static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp); | |
66 | static int progress_callback(void *clientp, double dltotal, double dlnow, | |
67 | double ultotal, double ulnow); | |
68 | bool SetupProxy(); | |
69 | CURL *curl; | |
70 | ||
71 | // Used by ServerMethods unused by https | |
72 | virtual void SendReq(FetchItem *) APT_OVERRIDE { exit(42); } | |
73 | virtual void RotateDNS() APT_OVERRIDE { exit(42); } | |
74 | ||
75 | public: | |
76 | ||
77 | virtual std::unique_ptr<ServerState> CreateServerState(URI const &uri) APT_OVERRIDE; | |
78 | using pkgAcqMethod::FetchResult; | |
79 | using pkgAcqMethod::FetchItem; | |
80 | ||
81 | explicit HttpsMethod(std::string &&pProg); | |
82 | virtual ~HttpsMethod(); | |
83 | }; | |
84 | ||
85 | #include <apt-pkg/strutl.h> | |
86 | URI Proxy; | |
87 | ||
88 | #endif |