git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5/6] http: Avoid limit of retrying request only twice
@ 2012-05-03 16:40 Nelson Benitez Leon
  2012-05-04  7:24 ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Nelson Benitez Leon @ 2012-05-03 16:40 UTC (permalink / raw)
  To: git; +Cc: Jeff King

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 c87c66c..1468ec7 100644
--- a/http.c
+++ b/http.c
@@ -912,10 +912,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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 5/6] http: Avoid limit of retrying request only twice
  2012-05-03 16:40 [PATCH 5/6] http: Avoid limit of retrying request only twice Nelson Benitez Leon
@ 2012-05-04  7:24 ` Jeff King
  2012-05-04 10:20   ` Nelson Benitez Leon
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2012-05-04  7:24 UTC (permalink / raw)
  To: Nelson Benitez Leon; +Cc: git

On Thu, May 03, 2012 at 06:40:28PM +0200, Nelson Benitez Leon wrote:

> 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>

We usually spell that as:

  From: Jeff King <peff@peff.net>

at the beginning of the email body (which lets am set the author
appropriately).

Other than that, the patch looks good to me (unsurprisingly :) ).

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 5/6] http: Avoid limit of retrying request only twice
  2012-05-04 10:20   ` Nelson Benitez Leon
@ 2012-05-04  9:28     ` Jeff King
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2012-05-04  9:28 UTC (permalink / raw)
  To: Nelson Benitez Leon; +Cc: git

On Fri, May 04, 2012 at 12:20:34PM +0200, Nelson Benitez Leon wrote:

> On 05/04/2012 09:24 AM, Jeff King wrote:
> > On Thu, May 03, 2012 at 06:40:28PM +0200, Nelson Benitez Leon wrote:
> > 
> >> [snip]
> >>
> >> Now we retry as long as we keep receiving HTTP_REAUTH, so the previous
> >> sequence correctly completes.
> >>
> >> Patch by Jeff King <peff@peff.net>
> > 
> > We usually spell that as:
> > 
> >   From: Jeff King <peff@peff.net>
> > 
> > at the beginning of the email body (which lets am set the author
> > appropriately).
> 
> Are you saying the first line of the email body? isn't that for the
> commit message first-line? I suppose you're not refering to the 'from
> field' of the email as I would need alter identities in my email client
> and found that cumbersome. Sorry for me not getting it and asking for
> clarification.

Yes, that's what I am saying. When Junio applies the patch using "git
am", git will recognize these extra "pseudo-headers" at the top of the
body, remove them from the commit message, and override the email
headers with them.

It does this for exactly this case; you can leave your email headers
intact, but still provide attribution to someone else.

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 5/6] http: Avoid limit of retrying request only twice
  2012-05-04  7:24 ` Jeff King
@ 2012-05-04 10:20   ` Nelson Benitez Leon
  2012-05-04  9:28     ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Nelson Benitez Leon @ 2012-05-04 10:20 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On 05/04/2012 09:24 AM, Jeff King wrote:
> On Thu, May 03, 2012 at 06:40:28PM +0200, Nelson Benitez Leon wrote:
> 
>> [snip]
>>
>> Now we retry as long as we keep receiving HTTP_REAUTH, so the previous
>> sequence correctly completes.
>>
>> Patch by Jeff King <peff@peff.net>
> 
> We usually spell that as:
> 
>   From: Jeff King <peff@peff.net>
> 
> at the beginning of the email body (which lets am set the author
> appropriately).

Are you saying the first line of the email body? isn't that for the
commit message first-line? I suppose you're not refering to the 'from
field' of the email as I would need alter identities in my email client
and found that cumbersome. Sorry for me not getting it and asking for
clarification.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-04  9:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-03 16:40 [PATCH 5/6] http: Avoid limit of retrying request only twice Nelson Benitez Leon
2012-05-04  7:24 ` Jeff King
2012-05-04 10:20   ` Nelson Benitez Leon
2012-05-04  9:28     ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).