http.hon commit Fix show-ref usage for --dereference. (9c13359)
   1#ifndef HTTP_H
   2#define HTTP_H
   3
   4#include "cache.h"
   5
   6#include <curl/curl.h>
   7#include <curl/easy.h>
   8
   9#if LIBCURL_VERSION_NUM >= 0x070908
  10#define USE_CURL_MULTI
  11#define DEFAULT_MAX_REQUESTS 5
  12#endif
  13
  14#if LIBCURL_VERSION_NUM < 0x070704
  15#define curl_global_cleanup() do { /* nothing */ } while(0)
  16#endif
  17#if LIBCURL_VERSION_NUM < 0x070800
  18#define curl_global_init(a) do { /* nothing */ } while(0)
  19#endif
  20
  21#if LIBCURL_VERSION_NUM < 0x070c04
  22#define NO_CURL_EASY_DUPHANDLE
  23#endif
  24
  25struct slot_results
  26{
  27        CURLcode curl_result;
  28        long http_code;
  29};
  30
  31struct active_request_slot
  32{
  33        CURL *curl;
  34        FILE *local;
  35        int in_use;
  36        CURLcode curl_result;
  37        long http_code;
  38        int *finished;
  39        struct slot_results *results;
  40        void *callback_data;
  41        void (*callback_func)(void *data);
  42        struct active_request_slot *next;
  43};
  44
  45struct buffer
  46{
  47        size_t posn;
  48        size_t size;
  49        void *buffer;
  50};
  51
  52/* Curl request read/write callbacks */
  53extern size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb,
  54                           struct buffer *buffer);
  55extern size_t fwrite_buffer(const void *ptr, size_t eltsize,
  56                            size_t nmemb, struct buffer *buffer);
  57extern size_t fwrite_null(const void *ptr, size_t eltsize,
  58                          size_t nmemb, struct buffer *buffer);
  59
  60/* Slot lifecycle functions */
  61extern struct active_request_slot *get_active_slot(void);
  62extern int start_active_slot(struct active_request_slot *slot);
  63extern void run_active_slot(struct active_request_slot *slot);
  64extern void finish_all_active_slots(void);
  65extern void release_active_slot(struct active_request_slot *slot);
  66
  67#ifdef USE_CURL_MULTI
  68extern void fill_active_slots(void);
  69extern void step_active_slots(void);
  70#endif
  71
  72extern void http_init(void);
  73extern void http_cleanup(void);
  74
  75extern int data_received;
  76extern int active_requests;
  77
  78#ifdef USE_CURL_MULTI
  79extern int max_requests;
  80extern CURLM *curlm;
  81#endif
  82#ifndef NO_CURL_EASY_DUPHANDLE
  83extern CURL *curl_default;
  84#endif
  85extern char curl_errorstr[CURL_ERROR_SIZE];
  86
  87extern int curl_ssl_verify;
  88extern char *ssl_cert;
  89#if LIBCURL_VERSION_NUM >= 0x070902
  90extern char *ssl_key;
  91#endif
  92#if LIBCURL_VERSION_NUM >= 0x070908
  93extern char *ssl_capath;
  94#endif
  95extern char *ssl_cainfo;
  96extern long curl_low_speed_limit;
  97extern long curl_low_speed_time;
  98
  99extern struct curl_slist *pragma_header;
 100extern struct curl_slist *no_range_header;
 101
 102extern struct active_request_slot *active_queue_head;
 103
 104#endif /* HTTP_H */