]> git.saurik.com Git - apt.git/blame - methods/https.h
handle complete responses to https range requests
[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
ae58a985 6 HTTP Acquire Method - This is the HTTP aquire method for APT.
d546f98d
MV
7
8 ##################################################################### */
9 /*}}}*/
10
f40db111
DK
11#ifndef APT_HTTPS_H
12#define APT_HTTPS_H
d546f98d 13
d546f98d
MV
14#include <iostream>
15#include <curl/curl.h>
16
fd46d305
DK
17#include "server.h"
18
d546f98d
MV
19using std::cout;
20using std::endl;
21
22class HttpsMethod;
472ff00e 23class FileFd;
d546f98d 24
fd46d305
DK
25class HttpsServerState : public ServerState
26{
27 protected:
28 virtual bool ReadHeaderLines(std::string &Data) { return false; }
29 virtual bool LoadNextResponse(bool const ToFile, FileFd * const File) { return false; }
30
31 public:
32 virtual bool WriteResponse(std::string const &Data) { return false; }
33
34 /** \brief Transfer the data from the socket */
35 virtual bool RunData(FileFd * const File) { return false; }
36
37 virtual bool Open() { return false; }
38 virtual bool IsOpen() { return false; }
39 virtual bool Close() { return false; }
40 virtual bool InitHashes(FileFd &File) { return false; }
41 virtual Hashes * GetHashes() { return NULL; }
42 virtual bool Die(FileFd &File) { return false; }
43 virtual bool Flush(FileFd * const File) { return false; }
44 virtual bool Go(bool ToFile, FileFd * const File) { return false; }
45
46 HttpsServerState(URI Srv, HttpsMethod *Owner);
47 virtual ~HttpsServerState() {Close();};
48};
49
d546f98d
MV
50class HttpsMethod : public pkgAcqMethod
51{
5085e660
MV
52 // minimum speed in bytes/se that triggers download timeout handling
53 static const int DL_MIN_SPEED = 10;
d546f98d
MV
54
55 virtual bool Fetch(FetchItem *);
fd46d305 56 static size_t parse_header(void *buffer, size_t size, size_t nmemb, void *userp);
d546f98d
MV
57 static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
58 static int progress_callback(void *clientp, double dltotal, double dlnow,
59 double ultotal, double ulnow);
21fd1746 60 void SetupProxy();
d546f98d
MV
61 CURL *curl;
62 FetchResult Res;
fd46d305 63 HttpsServerState *Server;
d546f98d
MV
64
65 public:
66 FileFd *File;
67
68 HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig)
69 {
70 File = 0;
71 curl = curl_easy_init();
72 };
45a9cc46
MV
73
74 ~HttpsMethod()
75 {
76 curl_easy_cleanup(curl);
77 };
d546f98d
MV
78};
79
472ff00e 80#include <apt-pkg/strutl.h>
d546f98d
MV
81URI Proxy;
82
83#endif