diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-04-16 19:28:11 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-16 19:28:11 +0900 |
commit | 3151a5fc454ddab36baa9ca91b51fb255cc5ee6f (patch) | |
tree | b1ed34ee30db5c3a79499defc32d5c8be501cc78 /http.c | |
parent | ec08c4fd951b9ea5136aaecbaec834ffb665da80 (diff) | |
parent | 3d10f72ef8eaa229b285d39b4848aac41e5a8b02 (diff) |
Merge branch 'jk/http-walker-status-fix'
dumb-http walker has been updated to share more error recovery
strategy with the normal codepath.
* jk/http-walker-status-fix:
http: use normalize_curl_result() instead of manual conversion
http: normalize curl results for dumb loose and alternates fetches
http: factor out curl result code normalization
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -1544,7 +1544,8 @@ char *get_remote_object_url(const char *url, const char *hex, return strbuf_detach(&buf, NULL); } -static int handle_curl_result(struct slot_results *results) +void normalize_curl_result(CURLcode *result, long http_code, + char *errorstr, size_t errorlen) { /* * If we see a failing http code with CURLE_OK, we have turned off @@ -1554,19 +1555,24 @@ static int handle_curl_result(struct slot_results *results) * Likewise, if we see a redirect (30x code), that means we turned off * redirect-following, and we should treat the result as an error. */ - if (results->curl_result == CURLE_OK && - results->http_code >= 300) { - results->curl_result = CURLE_HTTP_RETURNED_ERROR; + if (*result == CURLE_OK && http_code >= 300) { + *result = CURLE_HTTP_RETURNED_ERROR; /* * Normally curl will already have put the "reason phrase" * from the server into curl_errorstr; unfortunately without * FAILONERROR it is lost, so we can give only the numeric * status code. */ - xsnprintf(curl_errorstr, sizeof(curl_errorstr), + xsnprintf(errorstr, errorlen, "The requested URL returned error: %ld", - results->http_code); + http_code); } +} + +static int handle_curl_result(struct slot_results *results) +{ + normalize_curl_result(&results->curl_result, results->http_code, + curl_errorstr, sizeof(curl_errorstr)); if (results->curl_result == CURLE_OK) { credential_approve(&http_auth); |