2006-12-19 12:03:30 +01:00
|
|
|
// -*- mode: cpp; mode: fold -*-
|
|
|
|
|
// Description /*{{{*/// $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
|
|
|
|
|
// $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
|
|
|
|
|
/* ######################################################################
|
|
|
|
|
|
2014-02-22 18:34:33 +01:00
|
|
|
HTTP Acquire Method - This is the HTTP acquire method for APT.
|
2006-12-19 12:03:30 +01:00
|
|
|
|
|
|
|
|
##################################################################### */
|
|
|
|
|
/*}}}*/
|
|
|
|
|
|
2012-02-11 21:26:42 +01:00
|
|
|
#ifndef APT_HTTPS_H
|
|
|
|
|
#define APT_HTTPS_H
|
2006-12-19 12:03:30 +01:00
|
|
|
|
2014-03-05 22:11:25 +01:00
|
|
|
#include <apt-pkg/acquire-method.h>
|
|
|
|
|
|
2006-12-19 12:03:30 +01:00
|
|
|
#include <curl/curl.h>
|
2014-03-05 22:11:25 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <string>
|
2006-12-19 12:03:30 +01:00
|
|
|
|
2013-09-30 16:41:16 +02:00
|
|
|
#include "server.h"
|
|
|
|
|
|
2006-12-19 12:03:30 +01:00
|
|
|
using std::cout;
|
|
|
|
|
using std::endl;
|
|
|
|
|
|
2014-03-05 22:11:25 +01:00
|
|
|
class Hashes;
|
2006-12-19 12:03:30 +01:00
|
|
|
class HttpsMethod;
|
2011-09-19 19:14:19 +02:00
|
|
|
class FileFd;
|
2006-12-19 12:03:30 +01:00
|
|
|
|
2013-09-30 16:41:16 +02:00
|
|
|
class HttpsServerState : public ServerState
|
|
|
|
|
{
|
|
|
|
|
protected:
|
2014-03-01 15:11:42 +01:00
|
|
|
virtual bool ReadHeaderLines(std::string &/*Data*/) { return false; }
|
|
|
|
|
virtual bool LoadNextResponse(bool const /*ToFile*/, FileFd * const /*File*/) { return false; }
|
2013-09-30 16:41:16 +02:00
|
|
|
|
|
|
|
|
public:
|
2014-03-01 15:11:42 +01:00
|
|
|
virtual bool WriteResponse(std::string const &/*Data*/) { return false; }
|
2013-09-30 16:41:16 +02:00
|
|
|
|
|
|
|
|
/** \brief Transfer the data from the socket */
|
2014-03-01 15:11:42 +01:00
|
|
|
virtual bool RunData(FileFd * const /*File*/) { return false; }
|
2013-09-30 16:41:16 +02:00
|
|
|
|
|
|
|
|
virtual bool Open() { return false; }
|
|
|
|
|
virtual bool IsOpen() { return false; }
|
|
|
|
|
virtual bool Close() { return false; }
|
2014-03-01 15:11:42 +01:00
|
|
|
virtual bool InitHashes(FileFd &/*File*/) { return false; }
|
2013-09-30 16:41:16 +02:00
|
|
|
virtual Hashes * GetHashes() { return NULL; }
|
2014-03-01 15:11:42 +01:00
|
|
|
virtual bool Die(FileFd &/*File*/) { return false; }
|
|
|
|
|
virtual bool Flush(FileFd * const /*File*/) { return false; }
|
|
|
|
|
virtual bool Go(bool /*ToFile*/, FileFd * const /*File*/) { return false; }
|
2013-09-30 16:41:16 +02:00
|
|
|
|
|
|
|
|
HttpsServerState(URI Srv, HttpsMethod *Owner);
|
|
|
|
|
virtual ~HttpsServerState() {Close();};
|
|
|
|
|
};
|
|
|
|
|
|
2006-12-19 12:03:30 +01:00
|
|
|
class HttpsMethod : public pkgAcqMethod
|
|
|
|
|
{
|
2009-11-17 09:55:22 -06:00
|
|
|
// minimum speed in bytes/se that triggers download timeout handling
|
|
|
|
|
static const int DL_MIN_SPEED = 10;
|
2006-12-19 12:03:30 +01:00
|
|
|
|
|
|
|
|
virtual bool Fetch(FetchItem *);
|
2013-09-30 16:41:16 +02:00
|
|
|
static size_t parse_header(void *buffer, size_t size, size_t nmemb, void *userp);
|
2006-12-19 12:03:30 +01:00
|
|
|
static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
|
|
|
|
|
static int progress_callback(void *clientp, double dltotal, double dlnow,
|
|
|
|
|
double ultotal, double ulnow);
|
2007-07-10 15:06:12 -03:00
|
|
|
void SetupProxy();
|
2006-12-19 12:03:30 +01:00
|
|
|
CURL *curl;
|
|
|
|
|
FetchResult Res;
|
2013-09-30 16:41:16 +02:00
|
|
|
HttpsServerState *Server;
|
2014-08-26 19:20:04 -07:00
|
|
|
unsigned long long TotalWritten;
|
2006-12-19 12:03:30 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FileFd *File;
|
|
|
|
|
|
2014-08-26 19:20:04 -07:00
|
|
|
HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), TotalWritten(0), File(NULL)
|
2006-12-19 12:03:30 +01:00
|
|
|
{
|
|
|
|
|
File = 0;
|
|
|
|
|
curl = curl_easy_init();
|
|
|
|
|
};
|
2013-01-09 14:47:35 +01:00
|
|
|
|
|
|
|
|
~HttpsMethod()
|
|
|
|
|
{
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
};
|
2006-12-19 12:03:30 +01:00
|
|
|
};
|
|
|
|
|
|
2011-09-19 19:14:19 +02:00
|
|
|
#include <apt-pkg/strutl.h>
|
2006-12-19 12:03:30 +01:00
|
|
|
URI Proxy;
|
|
|
|
|
|
|
|
|
|
#endif
|