]> git.saurik.com Git - apt.git/blob - methods/https.h
debian/apt.postinst: chown _apt:root /etc/apt/auth.conf
[apt.git] / methods / https.h
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 <apt-pkg/acquire-method.h>
15
16 #include <curl/curl.h>
17 #include <iostream>
18 #include <stddef.h>
19 #include <string>
20
21 #include "server.h"
22
23 using std::cout;
24 using std::endl;
25
26 class Hashes;
27 class HttpsMethod;
28 class FileFd;
29
30 class HttpsServerState : public ServerState
31 {
32 protected:
33 virtual bool ReadHeaderLines(std::string &/*Data*/) { return false; }
34 virtual bool LoadNextResponse(bool const /*ToFile*/, FileFd * const /*File*/) { return false; }
35
36 public:
37 virtual bool WriteResponse(std::string const &/*Data*/) { return false; }
38
39 /** \brief Transfer the data from the socket */
40 virtual bool RunData(FileFd * const /*File*/) { return false; }
41
42 virtual bool Open() { return false; }
43 virtual bool IsOpen() { return false; }
44 virtual bool Close() { return false; }
45 virtual bool InitHashes(FileFd &/*File*/) { return false; }
46 virtual Hashes * GetHashes() { return NULL; }
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; }
50
51 HttpsServerState(URI Srv, HttpsMethod *Owner);
52 virtual ~HttpsServerState() {Close();};
53 };
54
55 class HttpsMethod : public pkgAcqMethod
56 {
57 // minimum speed in bytes/se that triggers download timeout handling
58 static const int DL_MIN_SPEED = 10;
59
60 virtual bool Fetch(FetchItem *);
61 virtual bool Configuration(std::string Message);
62
63 static size_t parse_header(void *buffer, size_t size, size_t nmemb, void *userp);
64 static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
65 static int progress_callback(void *clientp, double dltotal, double dlnow,
66 double ultotal, double ulnow);
67 void SetupProxy();
68 CURL *curl;
69 FetchResult Res;
70 HttpsServerState *Server;
71 unsigned long long TotalWritten;
72
73 public:
74 FileFd *File;
75
76 HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), Server(NULL), TotalWritten(0), File(NULL)
77 {
78 curl = curl_easy_init();
79 };
80
81 ~HttpsMethod()
82 {
83 curl_easy_cleanup(curl);
84 };
85 };
86
87 #include <apt-pkg/strutl.h>
88 URI Proxy;
89
90 #endif