]> git.saurik.com Git - apt.git/blame - methods/https.h
tests: fail testsuccess if notices are shown, too
[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>
830a1b8c 20#include <memory>
d546f98d 21
fd46d305
DK
22#include "server.h"
23
d546f98d
MV
24using std::cout;
25using std::endl;
26
453b82a3 27class Hashes;
d546f98d 28class HttpsMethod;
472ff00e 29class FileFd;
d546f98d 30
fd46d305
DK
31class HttpsServerState : public ServerState
32{
34faa8f7
DK
33 Hashes * Hash;
34
fd46d305 35 protected:
3b302846
DK
36 virtual bool ReadHeaderLines(std::string &/*Data*/) APT_OVERRIDE { return false; }
37 virtual bool LoadNextResponse(bool const /*ToFile*/, FileFd * const /*File*/) APT_OVERRIDE { return false; }
fd46d305
DK
38
39 public:
3b302846 40 virtual bool WriteResponse(std::string const &/*Data*/) APT_OVERRIDE { return false; }
fd46d305
DK
41
42 /** \brief Transfer the data from the socket */
3b302846 43 virtual bool RunData(FileFd * const /*File*/) APT_OVERRIDE { return false; }
fd46d305 44
3b302846
DK
45 virtual bool Open() APT_OVERRIDE { return false; }
46 virtual bool IsOpen() APT_OVERRIDE { return false; }
47 virtual bool Close() APT_OVERRIDE { return false; }
48 virtual bool InitHashes(HashStringList const &ExpectedHashes) APT_OVERRIDE;
49 virtual Hashes * GetHashes() APT_OVERRIDE;
50 virtual bool Die(FileFd &/*File*/) APT_OVERRIDE { return false; }
51 virtual bool Flush(FileFd * const /*File*/) APT_OVERRIDE { return false; }
52 virtual bool Go(bool /*ToFile*/, FileFd * const /*File*/) APT_OVERRIDE { return false; }
fd46d305
DK
53
54 HttpsServerState(URI Srv, HttpsMethod *Owner);
55 virtual ~HttpsServerState() {Close();};
56};
57
905fba60 58class HttpsMethod : public ServerMethod
d546f98d 59{
5085e660
MV
60 // minimum speed in bytes/se that triggers download timeout handling
61 static const int DL_MIN_SPEED = 10;
d546f98d 62
3b302846 63 virtual bool Fetch(FetchItem *) APT_OVERRIDE;
9983999d 64
fd46d305 65 static size_t parse_header(void *buffer, size_t size, size_t nmemb, void *userp);
d546f98d 66 static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
d61960d9
DK
67 static int progress_callback(void *clientp, double dltotal, double dlnow,
68 double ultotal, double ulnow);
21fd1746 69 void SetupProxy();
d546f98d 70 CURL *curl;
905fba60
DK
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:
d61960d9 77
3b302846 78 virtual bool Configuration(std::string Message) APT_OVERRIDE;
830a1b8c 79 virtual std::unique_ptr<ServerState> CreateServerState(URI const &uri) APT_OVERRIDE;
27925d82 80 using pkgAcqMethod::FetchResult;
dcbb364f 81 using pkgAcqMethod::FetchItem;
905fba60 82
258b9e51 83 HttpsMethod() : ServerMethod("https","1.2",Pipeline | SendConfig)
d546f98d 84 {
d546f98d
MV
85 curl = curl_easy_init();
86 };
45a9cc46
MV
87
88 ~HttpsMethod()
89 {
90 curl_easy_cleanup(curl);
91 };
d546f98d
MV
92};
93
472ff00e 94#include <apt-pkg/strutl.h>
d546f98d
MV
95URI Proxy;
96
97#endif