From: Junio C Hamano Date: Tue, 1 Nov 2011 22:42:25 +0000 (-0700) Subject: Merge jn/maint-http-error-message X-Git-Tag: v1.7.7.2~9 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/5b5d92aae910243ba12a737bbe117f0ae6ecf5c6?ds=inline;hp=-c Merge jn/maint-http-error-message * commit 'be22d92eac809ad2bfa2b7c83ad7cad5a15f1c43': http: avoid empty error messages for some curl errors http: remove extra newline in error message --- 5b5d92aae910243ba12a737bbe117f0ae6ecf5c6 diff --combined http.c index a59cac45d7,61a90896ec..fb3465f50c --- a/http.c +++ b/http.c @@@ -41,7 -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; @@@ -192,9 -191,6 +192,9 @@@ static int http_options(const char *var 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) @@@ -535,7 -531,6 +535,7 @@@ struct active_request_slot *get_active_ 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); @@@ -851,8 -846,13 +851,13 @@@ static int http_request(const char *url 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; @@@ -908,7 -908,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; } @@@ -1121,8 -1121,9 +1126,8 @@@ struct http_pack_request *new_http_pack 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", @@@ -1214,7 -1215,7 +1219,7 @@@ struct http_object_request *new_http_ob 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; @@@ -1252,6 -1253,8 +1257,6 @@@ goto abort; } - memset(&freq->stream, 0, sizeof(freq->stream)); - git_inflate_init(&freq->stream); git_SHA1_Init(&freq->c); @@@ -1326,6 -1329,7 +1331,6 @@@ return freq; abort: - free(filename); free(freq->url); free(freq); return NULL;