From 17966c0a63d25b1cc2dd1e98d30873e643bd581f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 11 Jul 2016 20:51:30 +0000 Subject: 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 Signed-off-by: Junio C Hamano --- http-walker.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'http-walker.c') diff --git a/http-walker.c b/http-walker.c index 9f28523a07..48f2df4d31 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 && -- cgit v1.2.3