git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tay Ray Chuan <rctay89@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	Yaroslav Halchenko <debian@onerussian.com>,
	Ilari Liusvaara <ilari.liusvaara@elisanet.fi>,
	"Shawn O. Pearce" <spearce@spearce.org>
Subject: [PATCH] http/remote-curl: coddle picky servers
Date: Thu, 21 Jan 2010 22:41:00 +0800	[thread overview]
Message-ID: <20100121224100.624c9c9d.rctay89@gmail.com> (raw)
In-Reply-To: <20100121140054.GH18213@onerussian.com>

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. In addition,
ensure that the "smart" http protocol is not used (a service has to be
specified with "?service=<service name>" to be conformant).

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Reported-and-tested-by: Yaroslav Halchenko <debian@onerussian.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

  reply	other threads:[~2010-01-21 14:41 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-21  0:47 problem cloning via http since v1.6.6-rc0 Yaroslav Halchenko
2010-01-21  1:34 ` Tay Ray Chuan
2010-01-21  1:36 ` Tay Ray Chuan
2010-01-21  2:33   ` Yaroslav Halchenko
2010-01-21  4:01     ` Tay Ray Chuan
2010-01-21  4:38       ` Yaroslav Halchenko
2010-01-21  5:08 ` Ilari Liusvaara
2010-01-21  6:47   ` Tay Ray Chuan
2010-01-21  7:51     ` Tay Ray Chuan
2010-01-21 14:00       ` Yaroslav Halchenko
2010-01-21 14:41         ` Tay Ray Chuan [this message]
2010-01-21 15:56           ` [PATCH] http/remote-curl: coddle picky servers Shawn O. Pearce
2010-01-21 16:07             ` Mike Hommey
2010-01-21 16:10               ` git fetch -v not at all verbose? Michael S. Tsirkin
2010-01-21 16:18                 ` Shawn O. Pearce
2010-01-21 16:35                   ` Michael S. Tsirkin
2010-01-21 16:57                     ` Shawn O. Pearce
2010-01-21 17:30                       ` Michael S. Tsirkin
2010-01-21 17:47                         ` Thomas Rast
2010-01-21 17:42                       ` Junio C Hamano
2010-11-03  9:52                         ` Michael S. Tsirkin
2010-11-03 16:14                           ` Junio C Hamano
2010-01-21 16:20               ` [PATCH] http/remote-curl: coddle picky servers Tay Ray Chuan
2010-01-21 16:24                 ` Shawn O. Pearce
2010-01-21 16:34                   ` Mike Hommey
2010-01-21 16:34                 ` Mike Hommey
2010-01-21 10:35     ` problem cloning via http since v1.6.6-rc0 Ilari Liusvaara
2010-01-21 11:36       ` Tay Ray Chuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100121224100.624c9c9d.rctay89@gmail.com \
    --to=rctay89@gmail.com \
    --cc=debian@onerussian.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ilari.liusvaara@elisanet.fi \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).