https.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. HTTP Acquire Method - This is the HTTP acquire method for APT.
  6. ##################################################################### */
  7. /*}}}*/
  8. #ifndef APT_HTTPS_H
  9. #define APT_HTTPS_H
  10. #include <iostream>
  11. #include <curl/curl.h>
  12. #include "server.h"
  13. using std::cout;
  14. using std::endl;
  15. class HttpsMethod;
  16. class FileFd;
  17. class HttpsServerState : public ServerState
  18. {
  19. protected:
  20. virtual bool ReadHeaderLines(std::string &Data) { return false; }
  21. virtual bool LoadNextResponse(bool const ToFile, FileFd * const File) { return false; }
  22. public:
  23. virtual bool WriteResponse(std::string const &Data) { return false; }
  24. /** \brief Transfer the data from the socket */
  25. virtual bool RunData(FileFd * const File) { return false; }
  26. virtual bool Open() { return false; }
  27. virtual bool IsOpen() { return false; }
  28. virtual bool Close() { return false; }
  29. virtual bool InitHashes(FileFd &File) { return false; }
  30. virtual Hashes * GetHashes() { return NULL; }
  31. virtual bool Die(FileFd &File) { return false; }
  32. virtual bool Flush(FileFd * const File) { return false; }
  33. virtual bool Go(bool ToFile, FileFd * const File) { return false; }
  34. HttpsServerState(URI Srv, HttpsMethod *Owner);
  35. virtual ~HttpsServerState() {Close();};
  36. };
  37. class HttpsMethod : public pkgAcqMethod
  38. {
  39. // minimum speed in bytes/se that triggers download timeout handling
  40. static const int DL_MIN_SPEED = 10;
  41. virtual bool Fetch(FetchItem *);
  42. static size_t parse_header(void *buffer, size_t size, size_t nmemb, void *userp);
  43. static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
  44. static int progress_callback(void *clientp, double dltotal, double dlnow,
  45. double ultotal, double ulnow);
  46. void SetupProxy();
  47. CURL *curl;
  48. FetchResult Res;
  49. HttpsServerState *Server;
  50. public:
  51. FileFd *File;
  52. HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), File(NULL)
  53. {
  54. File = 0;
  55. curl = curl_easy_init();
  56. };
  57. ~HttpsMethod()
  58. {
  59. curl_easy_cleanup(curl);
  60. };
  61. };
  62. #include <apt-pkg/strutl.h>
  63. URI Proxy;
  64. #endif