git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] http: Avoid limit of retrying request only twice

From
NLNelson Benitez Leon <nelsonjesus.benitez@seap.minhap.es>
Date
May 11, 2012, 13:13 UTC
Message-ID
<4FAD1092.2040805@seap.minhap.es>
From: Jeff King <peff@peff.net>

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 <peff@peff.net>
Signed-off-by: Nelson Benitez Leon <nbenitezl@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 http.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/http.c b/http.c
index 624d1a0..d34d741 100644
--- a/http.c
+++ b/http.c
@@ -852,10 +852,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)
-- 
1.7.7.6
Message 1 of 1 in “http: Avoid limit of retrying request only twice”
  1. 2/3 http: Avoid limit of retrying request only twiceNelson Benitez Leon, May 11, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.