]> git.saurik.com Git - apt.git/blame - methods/https.h
use pkgAcqMetaBase as the transactionManager
[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{
32 protected:
65512241
DK
33 virtual bool ReadHeaderLines(std::string &/*Data*/) { return false; }
34 virtual bool LoadNextResponse(bool const /*ToFile*/, FileFd * const /*File*/) { return false; }
fd46d305
DK
35
36 public:
65512241 37 virtual bool WriteResponse(std::string const &/*Data*/) { return false; }
fd46d305
DK
38
39 /** \brief Transfer the data from the socket */
65512241 40 virtual bool RunData(FileFd * const /*File*/) { return false; }
fd46d305
DK
41
42 virtual bool Open() { return false; }
43 virtual bool IsOpen() { return false; }
44 virtual bool Close() { return false; }
65512241 45 virtual bool InitHashes(FileFd &/*File*/) { return false; }
fd46d305 46 virtual Hashes * GetHashes() { return NULL; }
65512241
DK
47 virtual bool Die(FileFd &/*File*/) { return false; }
48 virtual bool Flush(FileFd * const /*File*/) { return false; }
49 virtual bool Go(bool /*ToFile*/, FileFd * const /*File*/) { return false; }
fd46d305
DK
50
51 HttpsServerState(URI Srv, HttpsMethod *Owner);
52 virtual ~HttpsServerState() {Close();};
53};
54
d546f98d
MV
55class HttpsMethod : public pkgAcqMethod
56{
5085e660
MV
57 // minimum speed in bytes/se that triggers download timeout handling
58 static const int DL_MIN_SPEED = 10;
d546f98d
MV
59
60 virtual bool Fetch(FetchItem *);
fd46d305 61 static size_t parse_header(void *buffer, size_t size, size_t nmemb, void *userp);
d546f98d
MV
62 static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
63 static int progress_callback(void *clientp, double dltotal, double dlnow,
64 double ultotal, double ulnow);
21fd1746 65 void SetupProxy();
d546f98d
MV
66 CURL *curl;
67 FetchResult Res;
fd46d305 68 HttpsServerState *Server;
d546f98d
MV
69
70 public:
71 FileFd *File;
72
9ce3cfc9 73 HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), File(NULL)
d546f98d
MV
74 {
75 File = 0;
76 curl = curl_easy_init();
77 };
45a9cc46
MV
78
79 ~HttpsMethod()
80 {
81 curl_easy_cleanup(curl);
82 };
d546f98d
MV
83};
84
472ff00e 85#include <apt-pkg/strutl.h>
d546f98d
MV
86URI Proxy;
87
88#endif