Skip to content

Commit da72ee8

Browse files
committed
Merge branch 'jk/http-walker-limit-redirect'
Update the error messages from the dumb-http client when it fails to obtain loose objects; we used to give sensible error message only upon 404 but we now forbid unexpected redirects that needs to be reported with something sensible. * jk/http-walker-limit-redirect: http-walker: complain about non-404 loose object errors
2 parents 8a2882f + 3680f16 commit da72ee8

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

http-walker.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,13 @@ static int fetch_object(struct walker *walker, unsigned char *sha1)
482482
* we turned off CURLOPT_FAILONERROR to avoid losing a
483483
* persistent connection and got CURLE_OK.
484484
*/
485-
if (req->http_code == 404 && req->curl_result == CURLE_OK &&
485+
if (req->http_code >= 300 && req->curl_result == CURLE_OK &&
486486
(starts_with(req->url, "http://") ||
487-
starts_with(req->url, "https://")))
487+
starts_with(req->url, "https://"))) {
488488
req->curl_result = CURLE_HTTP_RETURNED_ERROR;
489+
xsnprintf(req->errorstr, sizeof(req->errorstr),
490+
"HTTP request failed");
491+
}
489492

490493
if (obj_req->state == ABORTED) {
491494
ret = error("Request for %s aborted", hex);

http.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
20582058
if (c != CURLE_OK)
20592059
die("BUG: curl_easy_getinfo for HTTP code failed: %s",
20602060
curl_easy_strerror(c));
2061-
if (slot->http_code >= 400)
2061+
if (slot->http_code >= 300)
20622062
return size;
20632063
}
20642064

0 commit comments

Comments
 (0)