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