Skip to contentSkip to conversation

http: Avoid limit of retrying request only twice

PATCH In review Nelson Benitez Leon 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v5 4/5 http: Avoid limit of retrying request only twice

Current code, after receiving HTTP_REAUTH, only retried once, so couldn't do step 3 of the following sequence:

1. We make a request; proxy returns 407, because we didn't give it a password. We ask for the password and return HTTP_REAUTH.

2. We make another request; the proxy passes it to the actual server, who returns 401, because we didn't give an http password. We ask for the password and return HTTP_REAUTH.

3. We make a third request, but this time everybody is happy.

Now we retry as long as we keep receiving HTTP_REAUTH, so the previous sequence correctly completes.

Patch by Jeff King <[email protected]>

---
 http.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
http.c +7 -4
index d3d9d24..12dcaa1 100644
@@ -872,10 +872,13 @@ static int http_request(const char *url, void *result, int target, int options)
 static int http_request_reauth(const char *url, void *result, int target,
 			       int options)
 {
-	int ret = http_request(url, result, target, options);
-	if (ret != HTTP_REAUTH)
-		return ret;
-	return http_request(url, result, target, options);
+	int ret;
+
+	do {
+		ret = http_request(url, result, target, options);
+	} while (ret == HTTP_REAUTH);
+
+	return ret;
 }
 
 int http_get_strbuf(const char *url, struct strbuf *result, int options)
Signature · 1 line
1.7.7.6