summaryrefslogtreecommitdiff
path: root/http-walker.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-07-11 20:51:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-07-12 22:17:42 (GMT)
commit17966c0a63d25b1cc2dd1e98d30873e643bd581f (patch)
tree865db4ee901c1aef4befa2860e20173475006829 /http-walker.c
parent43b8bba6b60aa644456d7682b99357dd4778e8d6 (diff)
downloadgit-17966c0a63d25b1cc2dd1e98d30873e643bd581f.zip
git-17966c0a63d25b1cc2dd1e98d30873e643bd581f.tar.gz
git-17966c0a63d25b1cc2dd1e98d30873e643bd581f.tar.bz2
http: avoid disconnecting on 404s for loose objects
404s are common when fetching loose objects on static HTTP servers, and reestablishing a connection for every single 404 adds additional latency. Signed-off-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-walker.c')
-rw-r--r--http-walker.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/http-walker.c b/http-walker.c
index 9f28523..48f2df4 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -488,6 +488,15 @@ 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 == 404 && req->curl_result == CURLE_OK &&
+ (starts_with(req->url, "http://") ||
+ starts_with(req->url, "https://")))
+ req->curl_result = CURLE_HTTP_RETURNED_ERROR;
+
if (obj_req->state == ABORTED) {
ret = error("Request for %s aborted", hex);
} else if (req->curl_result != CURLE_OK &&