X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=http.c;h=fb3465f50c95ab9cb3e6fae1d1e594f6ae0b9c42;hb=afb6b561e3dad13df5d9df9731751a3d310c0854;hp=b2ae8de16db3abe2cad27249ae767f421aa6bb24;hpb=be5acb3b63af077db05788235a1d845d511e4561;p=git.git diff --git a/http.c b/http.c index b2ae8de16..fb3465f50 100644 --- a/http.c +++ b/http.c @@ -41,6 +41,7 @@ static long curl_low_speed_limit = -1; static long curl_low_speed_time = -1; static int curl_ftp_no_epsv; static const char *curl_http_proxy; +static const char *curl_cookie_file; static char *user_name, *user_pass; static const char *user_agent; @@ -191,6 +192,9 @@ static int http_options(const char *var, const char *value, void *cb) if (!strcmp("http.proxy", var)) return git_config_string(&curl_http_proxy, var, value); + if (!strcmp("http.cookiefile", var)) + return git_config_string(&curl_cookie_file, var, value); + if (!strcmp("http.postbuffer", var)) { http_post_buffer = git_config_int(var, value); if (http_post_buffer < LARGE_PACKET_MAX) @@ -531,6 +535,7 @@ struct active_request_slot *get_active_slot(void) slot->finished = NULL; slot->callback_data = NULL; slot->callback_func = NULL; + curl_easy_setopt(slot->curl, CURLOPT_COOKIEFILE, curl_cookie_file); curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, pragma_header); curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, curl_errorstr); curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, NULL); @@ -846,8 +851,13 @@ static int http_request(const char *url, void *result, int target, int options) init_curl_http_auth(slot->curl); ret = HTTP_REAUTH; } - } else + } else { + if (!curl_errorstr[0]) + strlcpy(curl_errorstr, + curl_easy_strerror(results.curl_result), + sizeof(curl_errorstr)); ret = HTTP_ERROR; + } } else { error("Unable to start HTTP request for %s", url); ret = HTTP_START_FAILED; @@ -903,7 +913,7 @@ int http_error(const char *url, int ret) { /* http_request has already handled HTTP_START_FAILED. */ if (ret != HTTP_START_FAILED) - error("%s while accessing %s\n", curl_errorstr, url); + error("%s while accessing %s", curl_errorstr, url); return ret; } @@ -1116,9 +1126,8 @@ struct http_pack_request *new_http_pack_request( struct strbuf buf = STRBUF_INIT; struct http_pack_request *preq; - preq = xmalloc(sizeof(*preq)); + preq = xcalloc(1, sizeof(*preq)); preq->target = target; - preq->range_header = NULL; end_url_with_slash(&buf, base_url); strbuf_addf(&buf, "objects/pack/pack-%s.pack", @@ -1210,7 +1219,7 @@ struct http_object_request *new_http_object_request(const char *base_url, struct curl_slist *range_header = NULL; struct http_object_request *freq; - freq = xmalloc(sizeof(*freq)); + freq = xcalloc(1, sizeof(*freq)); hashcpy(freq->sha1, sha1); freq->localfile = -1; @@ -1248,8 +1257,6 @@ struct http_object_request *new_http_object_request(const char *base_url, goto abort; } - memset(&freq->stream, 0, sizeof(freq->stream)); - git_inflate_init(&freq->stream); git_SHA1_Init(&freq->c); @@ -1324,7 +1331,6 @@ struct http_object_request *new_http_object_request(const char *base_url, return freq; abort: - free(filename); free(freq->url); free(freq); return NULL;