From: Junio C Hamano Date: Wed, 17 Oct 2012 17:29:24 +0000 (-0700) Subject: Merge branch 'jk/maint-http-half-auth-push' into maint X-Git-Tag: v1.7.12.4~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e98fa647aa5673cc95b6e9be1fdc13c0afa2cb37?ds=inline;hp=-c Merge branch 'jk/maint-http-half-auth-push' into maint * jk/maint-http-half-auth-push: http: fix segfault in handle_curl_result --- e98fa647aa5673cc95b6e9be1fdc13c0afa2cb37 diff --combined http.c index 345c171c5f,9334386d19..df9bb71086 --- a/http.c +++ b/http.c @@@ -4,7 -4,6 +4,7 @@@ #include "run-command.h" #include "url.h" #include "credential.h" +#include "version.h" int active_requests; int http_is_verbose; @@@ -300,7 -299,7 +300,7 @@@ static CURL *get_curl_handle(void curl_easy_setopt(result, CURLOPT_VERBOSE, 1); curl_easy_setopt(result, CURLOPT_USERAGENT, - user_agent ? user_agent : GIT_HTTP_USER_AGENT); + user_agent ? user_agent : git_user_agent()); if (curl_ftp_no_epsv) curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0); @@@ -745,10 -744,9 +745,9 @@@ char *get_remote_object_url(const char return strbuf_detach(&buf, NULL); } - int handle_curl_result(struct active_request_slot *slot) + int handle_curl_result(struct active_request_slot *slot, + struct slot_results *results) { - struct slot_results *results = slot->results; - if (results->curl_result == CURLE_OK) { credential_approve(&http_auth); return HTTP_OK; @@@ -764,12 -762,10 +763,12 @@@ return HTTP_REAUTH; } } else { +#if LIBCURL_VERSION_NUM >= 0x070c00 if (!curl_errorstr[0]) strlcpy(curl_errorstr, curl_easy_strerror(results->curl_result), sizeof(curl_errorstr)); +#endif return HTTP_ERROR; } } @@@ -818,11 -814,10 +817,11 @@@ static int http_request(const char *url curl_easy_setopt(slot->curl, CURLOPT_URL, url); curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "gzip"); if (start_active_slot(slot)) { run_active_slot(slot); - ret = handle_curl_result(slot); + ret = handle_curl_result(slot, &results); } else { error("Unable to start HTTP request for %s", url); ret = HTTP_START_FAILED; @@@ -926,7 -921,7 +925,7 @@@ static char *fetch_pack_index(unsigned tmp = strbuf_detach(&buf, NULL); if (http_get_file(url, tmp, 0) != HTTP_OK) { - error("Unable to get pack index %s\n", url); + error("Unable to get pack index %s", url); free(tmp); tmp = NULL; } diff --combined remote-curl.c index a2696082fb,6054e47929..468ccef58a --- a/remote-curl.c +++ b/remote-curl.c @@@ -95,7 -95,7 +95,7 @@@ static struct discovery* discover_refs( struct strbuf buffer = STRBUF_INIT; struct discovery *last = last_discovery; char *refs_url; - int http_ret, is_http = 0, proto_git_candidate = 1; + int http_ret, is_http = 0; if (last && !strcmp(service, last->service)) return last; @@@ -113,6 -113,19 +113,6 @@@ refs_url = strbuf_detach(&buffer, NULL); http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE); - - /* try again with "plain" url (no ? or & appended) */ - if (http_ret != HTTP_OK && http_ret != HTTP_NOAUTH) { - free(refs_url); - strbuf_reset(&buffer); - - proto_git_candidate = 0; - strbuf_addf(&buffer, "%sinfo/refs", url); - refs_url = strbuf_detach(&buffer, NULL); - - http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE); - } - switch (http_ret) { case HTTP_OK: break; @@@ -131,7 -144,8 +131,7 @@@ last->buf_alloc = strbuf_detach(&buffer, &last->len); last->buf = last->buf_alloc; - if (is_http && proto_git_candidate - && 5 <= last->len && last->buf[4] == '#') { + if (is_http && 5 <= last->len && last->buf[4] == '#') { /* smart HTTP response; validate that the service * pkt-line matches our request. */ @@@ -355,7 -369,7 +355,7 @@@ static int run_slot(struct active_reque slot->curl_result = curl_easy_perform(slot->curl); finish_active_slot(slot); - err = handle_curl_result(slot); + err = handle_curl_result(slot, &results); if (err != HTTP_OK && err != HTTP_REAUTH) { error("RPC failed; result=%d, HTTP code = %ld", results.curl_result, results.http_code); @@@ -379,7 -393,7 +379,7 @@@ static int probe_rpc(struct rpc_state * curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0); curl_easy_setopt(slot->curl, CURLOPT_POST, 1); curl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url); - curl_easy_setopt(slot->curl, CURLOPT_ENCODING, ""); + curl_easy_setopt(slot->curl, CURLOPT_ENCODING, NULL); curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, "0000"); curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4); curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers); @@@ -435,7 -449,7 +435,7 @@@ static int post_rpc(struct rpc_state *r curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0); curl_easy_setopt(slot->curl, CURLOPT_POST, 1); curl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url); - curl_easy_setopt(slot->curl, CURLOPT_ENCODING, ""); + curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "gzip"); headers = curl_slist_append(headers, rpc->hdr_content_type); headers = curl_slist_append(headers, rpc->hdr_accept);