Skip to content

Commit 8d677ed

Browse files
peffgitster
authored andcommitted
http: retry authentication failures for all http requests
Commit 42653c0 (Prompt for a username when an HTTP request 401s, 2010-04-01) changed http_get_strbuf to prompt for credentials when we receive a 401, but didn't touch http_get_file. The latter is called only for dumb http; while it's usually the case that people don't use authentication on top of dumb http, there is no reason not to allow both types of requests to use this feature. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28d0c10 commit 8d677ed

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

http.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -846,13 +846,18 @@ static int http_request(const char *url, void *result, int target, int options)
846846
return ret;
847847
}
848848

849+
static int http_request_reauth(const char *url, void *result, int target,
850+
int options)
851+
{
852+
int ret = http_request(url, result, target, options);
853+
if (ret != HTTP_REAUTH)
854+
return ret;
855+
return http_request(url, result, target, options);
856+
}
857+
849858
int http_get_strbuf(const char *url, struct strbuf *result, int options)
850859
{
851-
int http_ret = http_request(url, result, HTTP_REQUEST_STRBUF, options);
852-
if (http_ret == HTTP_REAUTH) {
853-
http_ret = http_request(url, result, HTTP_REQUEST_STRBUF, options);
854-
}
855-
return http_ret;
860+
return http_request_reauth(url, result, HTTP_REQUEST_STRBUF, options);
856861
}
857862

858863
/*
@@ -875,7 +880,7 @@ static int http_get_file(const char *url, const char *filename, int options)
875880
goto cleanup;
876881
}
877882

878-
ret = http_request(url, result, HTTP_REQUEST_FILE, options);
883+
ret = http_request_reauth(url, result, HTTP_REQUEST_FILE, options);
879884
fclose(result);
880885

881886
if ((ret == HTTP_OK) && move_temp_to_file(tmpfile.buf, filename))

0 commit comments

Comments
 (0)