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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 18, 2011 at 03:50 UTC 8d677edc4fa3fd1fe12b49bf279aaad5be89b81c
1 file changed +11 -6
http.c
+11 -6
@@ -846,13 +846,18 @@ static int http_request(const char *url, void *result, int target, int options)
846 return ret;
847 }
848
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 +
858 int http_get_strbuf(const char *url, struct strbuf *result, int options)
859 {
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);
861 }
862
863 /*
@@ -875,7 +880,7 @@ static int http_get_file(const char *url, const char *filename, int options)
880 goto cleanup;
881 }
882
878 - ret = http_request(url, result, HTTP_REQUEST_FILE, options);
883 + ret = http_request_reauth(url, result, HTTP_REQUEST_FILE, options);
884 fclose(result);
885
886 if ((ret == HTTP_OK) && move_temp_to_file(tmpfile.buf, filename))