{"thread":{"id":"29935","subject":"[PATCH v5 4/5] http: Avoid limit of retrying request only twice","startedAt":"2012-03-13T14:05:40Z","lastAt":"2012-03-13T14:05:40Z","messageCount":1,"participants":["Nelson Benitez Leon"],"isPatch":true,"patchVersion":5,"patchTotal":5},"messages":[{"id":"186854","messageId":"4F5F5434.1070601@seap.minhap.es","threadId":"29935","inReplyTo":null,"subject":"[PATCH v5 4/5] http: Avoid limit of retrying request only twice","fromName":"Nelson Benitez Leon","fromEmail":"nelsonjesus.benitez@seap.minhap.es","sentAt":"2012-03-13T14:05:40Z","receivedAt":"2012-03-13T14:05:40Z","isPatch":true,"sender":{"key":"nelsonjesus.benitez@seap.minhap.es","avatar":null},"body":"\nCurrent code, after receiving HTTP_REAUTH, only retried\nonce, so couldn't do step 3 of the following sequence:\n\n  1. We make a request; proxy returns 407, because we didn't give it a\n     password. We ask for the password and return HTTP_REAUTH.\n\n  2. We make another request; the proxy passes it to the actual server,\n     who returns 401, because we didn't give an http password. We ask\n     for the password and return HTTP_REAUTH.\n\n  3. We make a third request, but this time everybody is happy.\n\nNow we retry as long as we keep receiving HTTP_REAUTH, so the previous\nsequence correctly completes.\n\nPatch by Jeff King <peff@peff.net>\n\nSigned-off-by: Nelson Benitez Leon <nbenitezl@gmail.com>\n---\n http.c |   11 +++++++----\n 1 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex d3d9d24..12dcaa1 100644\n--- a/http.c\n+++ b/http.c\n@@ -872,10 +872,13 @@ static int http_request(const char *url, void *result, int target, int options)\n static int http_request_reauth(const char *url, void *result, int target,\n \t\t\t       int options)\n {\n-\tint ret = http_request(url, result, target, options);\n-\tif (ret != HTTP_REAUTH)\n-\t\treturn ret;\n-\treturn http_request(url, result, target, options);\n+\tint ret;\n+\n+\tdo {\n+\t\tret = http_request(url, result, target, options);\n+\t} while (ret == HTTP_REAUTH);\n+\n+\treturn ret;\n }\n \n int http_get_strbuf(const char *url, struct strbuf *result, int options)\n-- \n1.7.7.6\n"}]}