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

[PATCH 3/6] remote-curl: don't retry auth failures with dumb protocol

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Oct 14, 2011, 07:40 UTC
Message-ID
<28d0c1017a10a93ce165a2d4e9fb6a691a933bd3.1318577792.git.git@drmicha.warpmail.net>
In-Reply-To
<4E9692BF.8040705@drmicha.warpmail.net>
From: Jeff King <peff@peff.net>

When fetching an http URL, we first try fetching info/refs with an extra "service" parameter. This will work for a smart-http server, or a dumb server which ignores extra parameters when fetching files. If that fails, we retry without the extra parameter to remain compatible with dumb servers which didn't like our first request.

If the server returned a "401 Unauthorized", indicating that the credentials we provided were not good, there is not much point in retrying. With the current code, we just waste an extra round trip to the HTTP server before failing.

But as the http code becomes smarter about throwing away rejected credentials and re-prompting the user for new ones (which it will later in this series), this will become more confusing. At some point we will stop asking for credentials to retry smart http, and will be asking for credentials to retry dumb http. So now we're not only wasting an extra HTTP round trip for something that is unlikely to work, but we're making the user re-type their password for it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 remote-curl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c
index faaeda4..6c24ab1 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -115,7 +115,7 @@ static struct discovery* discover_refs(const char *service)
 	http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
 
 	/* try again with "plain" url (no ? or & appended) */
-	if (http_ret != HTTP_OK) {
+	if (http_ret != HTTP_OK && http_ret != HTTP_NOAUTH) {
 		free(refs_url);
 		strbuf_reset(&buffer);
 
-- 
1.7.7.338.g0156b
Previous: Michael J GruberNext: Michael J Gruber
Message 26 of 30 in “Git ksshaskpass to play nice with https and kwallet”
  1. Michael J GruberOct 4, 2011
  2. Jeff KingOct 4, 2011
  3. Michael J GruberOct 4, 2011
  4. Jeff KingOct 4, 2011
  5. Michael J GruberOct 4, 2011
  6. Jeff KingOct 4, 2011
  7. Michael J GruberOct 4, 2011
  8. Jeff KingOct 5, 2011
  9. Jeff KingOct 5, 2011
  10. Michael J GruberOct 6, 2011
  11. remote-curl: Obey passed URLMichael J Gruber, Oct 6, 2011
  12. Jeff KingOct 6, 2011
  13. Jeff KingOct 6, 2011
  14. Michael J GruberOct 12, 2011
  15. http_init: accept separate URL parameterJeff King, Oct 12, 2011
  16. Jeff KingOct 12, 2011
  17. Junio C HamanoOct 12, 2011
  18. Jeff KingOct 12, 2011
  19. Michael J GruberOct 13, 2011
  20. 0/6 http-auth-earlyMichael J Gruber, Oct 14, 2011
  21. Jeff KingOct 14, 2011
  22. Michael J GruberOct 14, 2011
  23. Junio C HamanoOct 14, 2011
  24. 1/6 url: decode buffers that are not NUL-terminatedMichael J Gruber, Oct 14, 2011
  25. 2/6 improve httpd auth testsMichael J Gruber, Oct 14, 2011
  26. 3/6 remote-curl: don't retry auth failures with dumb protocolMichael J Gruber, Oct 14, 2011
  27. 4/6 http: retry authentication failures for all http requestsMichael J Gruber, Oct 14, 2011
  28. 5/6 http: use hostname in credential descriptionMichael J Gruber, Oct 14, 2011
  29. 6/6 http_init: accept separate URL parameterMichael J Gruber, Oct 14, 2011
  30. Tay Ray ChuanOct 13, 2011

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.