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

Re: problem cloning via http since v1.6.6-rc0

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Jan 21, 2010, 07:51 UTC
Message-ID
<20100121155136.17b59e8f.rctay89@gmail.com>
In-Reply-To
<be6fef0d1001202247l7467a14ap8181eb3ed830167a@mail.gmail.com>
Hi,

On Thu, 21 Jan 2010 14:47:37 +0800 Tay Ray Chuan <rctay89@gmail.com> wrote:

Show 18 quoted lines
> On Thu, Jan 21, 2010 at 1:08 PM, Ilari Liusvaara
> <ilari.liusvaara@elisanet.fi> wrote:
> > Looks like remote-curl (which handles http) issues request for:
> >
> > '.../info/refs?service=git-upload-pack'
> >
> > And expects that if there is no smart HTTP server there for the request to be
> > interpretted as:
> >
> > '.../info/refs'
> >
> > (i.e. webserver would ignore the query). This isn't true for git.debian.org.
> > Requesting the latter works (and the data formatting looks sane), but the
> > former is 404. This causes the fetch to fail.
> 
> afaik, putting a "?var1=val1&var2=...." still makes it a normal GET
> request, even if the url requested is just a plain file and not some
> cgi handler that uses those variables/values.

Yaroslav, sorry for making you run in circles - it really is git's fault (sorta).

In recent versions of git, we were sending out the GET request for info/refs with a query string (?serivce=<service name>). I'm not sure why, but your server is not playing nice when the query string is appended.

Could you try this patch and see if it solves the issue? I manage to clone your repo successfully with it.

-- 
Cheers,
Ray Chuan

-->8--
Subject: [PATCH] http/remote-curl: coddle picky servers

When "info/refs" is a static file and not behind a CGI handler, some
servers may not handle a GET request for it with a query string
appended (eg. "?foo=bar") properly.

If such a request fails, retry it sans the query string, and also
discount the possibility of using the "smart" protocol (since no
service is specified with "?service=<service name>").

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 remote-curl.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/remote-curl.c b/remote-curl.c
index 1361006..a904164 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -102,7 +102,7 @@ static struct discovery* discover_refs(const char *service)
 	struct strbuf buffer = STRBUF_INIT;
 	struct discovery *last = last_discovery;
 	char *refs_url;
-	int http_ret, is_http = 0;
+	int http_ret, is_http = 0, proto_git_candidate = 1;
 
 	if (last && !strcmp(service, last->service))
 		return last;
@@ -121,6 +121,19 @@ static struct discovery* discover_refs(const char *service)
 
 	init_walker();
 	http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
+
+	/* try again with "plain" url (no ? or & appended) */
+	if (http_ret != HTTP_OK) {
+		free(refs_url);
+		strbuf_reset(&buffer);
+
+		proto_git_candidate = 0;
+		strbuf_addf(&buffer, "%s/info/refs", url);
+		refs_url = strbuf_detach(&buffer, NULL);
+
+		http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
+	}
+
 	switch (http_ret) {
 	case HTTP_OK:
 		break;
@@ -137,7 +150,8 @@ static struct discovery* discover_refs(const char *service)
 	last->buf_alloc = strbuf_detach(&buffer, &last->len);
 	last->buf = last->buf_alloc;
 
-	if (is_http && 5 <= last->len && last->buf[4] == '#') {
+	if (is_http && proto_git_candidate
+		&& 5 <= last->len && last->buf[4] == '#') {
 		/* smart HTTP response; validate that the service
 		 * pkt-line matches our request.
 		 */
-- 
1.6.6.1.337.g96bc8
Previous: Tay Ray ChuanNext: Yaroslav Halchenko
Message 9 of 28 in “problem cloning via http since v1.6.6-rc0”
  1. Yaroslav HalchenkoJan 21, 2010
  2. Tay Ray ChuanJan 21, 2010
  3. Tay Ray ChuanJan 21, 2010
  4. Yaroslav HalchenkoJan 21, 2010
  5. Tay Ray ChuanJan 21, 2010
  6. Yaroslav HalchenkoJan 21, 2010
  7. Ilari LiusvaaraJan 21, 2010
  8. Tay Ray ChuanJan 21, 2010
  9. Tay Ray ChuanJan 21, 2010
  10. Yaroslav HalchenkoJan 21, 2010
  11. http/remote-curl: coddle picky serversTay Ray Chuan, Jan 21, 2010
  12. Shawn O. PearceJan 21, 2010
  13. Mike HommeyJan 21, 2010
  14. git fetch -v not at all verbose?Michael S. Tsirkin, Jan 21, 2010
  15. Shawn O. PearceJan 21, 2010
  16. Michael S. TsirkinJan 21, 2010
  17. Shawn O. PearceJan 21, 2010
  18. Michael S. TsirkinJan 21, 2010
  19. Thomas RastJan 21, 2010
  20. Junio C HamanoJan 21, 2010
  21. Michael S. TsirkinNov 3, 2010
  22. Junio C HamanoNov 3, 2010
  23. Tay Ray ChuanJan 21, 2010
  24. Shawn O. PearceJan 21, 2010
  25. Mike HommeyJan 21, 2010
  26. Mike HommeyJan 21, 2010
  27. Ilari LiusvaaraJan 21, 2010
  28. Tay Ray ChuanJan 21, 2010

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.