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-walker.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-walker.c')
-rw-r--r-- | http-walker.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/http-walker.c b/http-walker.c index 8ae5d76c6a..48b1b3a193 100644 --- a/http-walker.c +++ b/http-walker.c @@ -98,6 +98,11 @@ static void process_object_response(void *callback_data) process_http_object_request(obj_req->req); obj_req->state = COMPLETE; + normalize_curl_result(&obj_req->req->curl_result, + obj_req->req->http_code, + obj_req->req->errorstr, + sizeof(obj_req->req->errorstr)); + /* Use alternates if necessary */ if (missing_target(obj_req->req)) { fetch_alternates(walker, alt->base); @@ -208,6 +213,9 @@ static void process_alternates_response(void *callback_data) char *data; int i = 0; + normalize_curl_result(&slot->curl_result, slot->http_code, + curl_errorstr, sizeof(curl_errorstr)); + if (alt_req->http_specific) { if (slot->curl_result != CURLE_OK || !alt_req->buffer->len) { @@ -518,17 +526,8 @@ static int fetch_object(struct walker *walker, unsigned char *sha1) req->localfile = -1; } - /* - * we turned off CURLOPT_FAILONERROR to avoid losing a - * persistent connection and got CURLE_OK. - */ - if (req->http_code >= 300 && req->curl_result == CURLE_OK && - (starts_with(req->url, "http://") || - starts_with(req->url, "https://"))) { - req->curl_result = CURLE_HTTP_RETURNED_ERROR; - xsnprintf(req->errorstr, sizeof(req->errorstr), - "HTTP request failed"); - } + normalize_curl_result(&req->curl_result, req->http_code, + req->errorstr, sizeof(req->errorstr)); if (obj_req->state == ABORTED) { ret = error("Request for %s aborted", hex); |