13 #if LIBCURL_VERSION_NUM < 0x071304
14 #error "your libcurl version is too old; Git requires curl >= 7.19.4"
17 #define DEFAULT_MAX_REQUESTS 5
23 long http_connectcode;
26 struct active_request_slot {
32 struct slot_results *results;
34 void (*callback_func)(void *data);
35 struct active_request_slot *next;
43 /* Curl request read/write callbacks */
44 extern size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);
45 extern size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);
46 extern size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);
47 extern curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);
49 /* Slot lifecycle functions */
50 extern struct active_request_slot *get_active_slot(void);
51 extern int start_active_slot(struct active_request_slot *slot);
52 extern void run_active_slot(struct active_request_slot *slot);
53 extern void finish_all_active_slots(void);
56 * This will run one slot to completion in a blocking manner, similar to how
57 * curl_easy_perform would work (but we don't want to use that, because
58 * we do not want to intermingle calls to curl_multi and curl_easy).
61 int run_one_slot(struct active_request_slot *slot,
62 struct slot_results *results);
64 extern void fill_active_slots(void);
65 extern void add_fill_function(void *data, int (*fill)(void *));
66 extern void step_active_slots(void);
68 extern void http_init(struct remote *remote, const char *url,
70 extern void http_cleanup(void);
71 extern struct curl_slist *http_copy_default_headers(void);
73 extern long int git_curl_ipresolve;
74 extern int active_requests;
75 extern int http_is_verbose;
76 extern ssize_t http_post_buffer;
77 extern struct credential http_auth;
79 extern char curl_errorstr[CURL_ERROR_SIZE];
81 enum http_follow_config {
86 extern enum http_follow_config http_follow_config;
88 static inline int missing__target(int code, int result)
90 return /* file:// URL -- do we ever use one??? */
91 (result == CURLE_FILE_COULDNT_READ_FILE) ||
92 /* http:// and https:// URL */
93 (code == 404 && result == CURLE_HTTP_RETURNED_ERROR) ||
95 (code == 550 && result == CURLE_FTP_COULDNT_RETR_FILE)
99 #define missing_target(a) missing__target((a)->http_code, (a)->curl_result)
101 /* Helpers for modifying and creating URLs */
102 extern void append_remote_object_url(struct strbuf *buf, const char *url,
104 int only_two_digit_prefix);
105 extern char *get_remote_object_url(const char *url, const char *hex,
106 int only_two_digit_prefix);
108 /* Options for http_get_*() */
109 struct http_get_options {
114 /* If non-NULL, returns the content-type of the response. */
115 struct strbuf *content_type;
118 * If non-NULL, and content_type above is non-NULL, returns
119 * the charset parameter from the content-type. If none is
120 * present, returns an empty string.
122 struct strbuf *charset;
125 * If non-NULL, returns the URL we ended up at, including any
126 * redirects we followed.
128 struct strbuf *effective_url;
131 * If both base_url and effective_url are non-NULL, the base URL will
132 * be munged to reflect any redirections going from the requested url
133 * to effective_url. See the definition of update_url_from_redirect
136 struct strbuf *base_url;
138 struct string_list *extra_headers;
141 /* Return values for http_get_*() */
143 #define HTTP_MISSING_TARGET 1
145 #define HTTP_START_FAILED 3
146 #define HTTP_REAUTH 4
147 #define HTTP_NOAUTH 5
150 * Requests a URL and stores the result in a strbuf.
152 * If the result pointer is NULL, a HTTP HEAD request is made instead of GET.
154 int http_get_strbuf(const char *url, struct strbuf *result, struct http_get_options *options);
156 extern int http_fetch_ref(const char *base, struct ref *ref);
158 /* Helpers for fetching packs */
159 extern int http_get_info_packs(const char *base_url,
160 struct packed_git **packs_head);
162 struct http_pack_request {
164 struct packed_git *target;
165 struct packed_git **lst;
167 char tmpfile[PATH_MAX];
168 struct active_request_slot *slot;
171 extern struct http_pack_request *new_http_pack_request(
172 struct packed_git *target, const char *base_url);
173 extern int finish_http_pack_request(struct http_pack_request *preq);
174 extern void release_http_pack_request(struct http_pack_request *preq);
176 /* Helpers for fetching object */
177 struct http_object_request {
179 char tmpfile[PATH_MAX];
181 CURLcode curl_result;
182 char errorstr[CURL_ERROR_SIZE];
184 unsigned char sha1[20];
185 unsigned char real_sha1[20];
190 struct active_request_slot *slot;
193 extern struct http_object_request *new_http_object_request(
194 const char *base_url, unsigned char *sha1);
195 extern void process_http_object_request(struct http_object_request *freq);
196 extern int finish_http_object_request(struct http_object_request *freq);
197 extern void abort_http_object_request(struct http_object_request *freq);
198 extern void release_http_object_request(struct http_object_request *freq);
200 /* setup routine for curl_easy_setopt CURLOPT_DEBUGFUNCTION */
201 void setup_curl_trace(CURL *handle);