diff options
Diffstat (limited to 'http.h')
-rw-r--r-- | http.h | 66 |
1 files changed, 17 insertions, 49 deletions
@@ -1,58 +1,17 @@ #ifndef HTTP_H #define HTTP_H -#include "cache.h" +struct packed_git; + +#include "git-zlib.h" #include <curl/curl.h> #include <curl/easy.h> #include "strbuf.h" #include "remote.h" -#include "url.h" - -/* - * We detect based on the cURL version if multi-transfer is - * usable in this implementation and define this symbol accordingly. - * This shouldn't be set by the Makefile or by the user (e.g. via CFLAGS). - */ -#undef USE_CURL_MULTI -#if LIBCURL_VERSION_NUM >= 0x071000 -#define USE_CURL_MULTI #define DEFAULT_MAX_REQUESTS 5 -#endif - -#if LIBCURL_VERSION_NUM < 0x070704 -#define curl_global_cleanup() do { /* nothing */ } while (0) -#endif - -#if LIBCURL_VERSION_NUM < 0x070800 -#define curl_global_init(a) do { /* nothing */ } while (0) -#elif LIBCURL_VERSION_NUM >= 0x070c00 -#define curl_global_init(a) curl_global_init_mem(a, xmalloc, free, \ - xrealloc, xstrdup, xcalloc) -#endif - -#if (LIBCURL_VERSION_NUM < 0x070c04) || (LIBCURL_VERSION_NUM == 0x071000) -#define NO_CURL_EASY_DUPHANDLE -#endif - -#if LIBCURL_VERSION_NUM < 0x070a03 -#define CURLE_HTTP_RETURNED_ERROR CURLE_HTTP_NOT_FOUND -#endif - -#if LIBCURL_VERSION_NUM < 0x070c03 -#define NO_CURL_IOCTL -#endif - -/* - * CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4, - * and the constants were known as CURLFTPSSL_* -*/ -#if !defined(CURLOPT_USE_SSL) && defined(CURLOPT_FTP_SSL) -#define CURLOPT_USE_SSL CURLOPT_FTP_SSL -#define CURLUSESSL_TRY CURLFTPSSL_TRY -#endif struct slot_results { CURLcode curl_result; @@ -82,9 +41,7 @@ struct buffer { size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf); size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf); size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf); -#ifndef NO_CURL_IOCTL -curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp); -#endif +int seek_buffer(void *clientp, curl_off_t offset, int origin); /* Slot lifecycle functions */ struct active_request_slot *get_active_slot(void); @@ -101,11 +58,9 @@ void finish_all_active_slots(void); int run_one_slot(struct active_request_slot *slot, struct slot_results *results); -#ifdef USE_CURL_MULTI void fill_active_slots(void); void add_fill_function(void *data, int (*fill)(void *)); void step_active_slots(void); -#endif void http_init(struct remote *remote, const char *url, int proactive_auth); @@ -200,6 +155,7 @@ struct http_get_options { #define HTTP_START_FAILED 3 #define HTTP_REAUTH 4 #define HTTP_NOAUTH 5 +#define HTTP_NOMATCHPUBLICKEY 6 /* * Requests a URL and stores the result in a strbuf. @@ -208,12 +164,24 @@ struct http_get_options { */ int http_get_strbuf(const char *url, struct strbuf *result, struct http_get_options *options); +/* + * Downloads a URL and stores the result in the given file. + * + * If a previous interrupted download is detected (i.e. a previous temporary + * file is still around) the download is resumed. + */ +int http_get_file(const char *url, const char *filename, + struct http_get_options *options); + int http_fetch_ref(const char *base, struct ref *ref); /* Helpers for fetching packs */ int http_get_info_packs(const char *base_url, struct packed_git **packs_head); +/* Helper for getting Accept-Language header */ +const char *http_get_accept_language_header(void); + struct http_pack_request { char *url; |