retry request without query when info/refs?query fails
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> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
8f376a50ec
commit
703e6e76a1
@ -102,7 +102,7 @@ static struct discovery* discover_refs(const char *service)
|
|||||||
struct strbuf buffer = STRBUF_INIT;
|
struct strbuf buffer = STRBUF_INIT;
|
||||||
struct discovery *last = last_discovery;
|
struct discovery *last = last_discovery;
|
||||||
char *refs_url;
|
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))
|
if (last && !strcmp(service, last->service))
|
||||||
return last;
|
return last;
|
||||||
@ -121,6 +121,19 @@ static struct discovery* discover_refs(const char *service)
|
|||||||
|
|
||||||
init_walker();
|
init_walker();
|
||||||
http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
|
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) {
|
switch (http_ret) {
|
||||||
case HTTP_OK:
|
case HTTP_OK:
|
||||||
break;
|
break;
|
||||||
@ -137,7 +150,8 @@ static struct discovery* discover_refs(const char *service)
|
|||||||
last->buf_alloc = strbuf_detach(&buffer, &last->len);
|
last->buf_alloc = strbuf_detach(&buffer, &last->len);
|
||||||
last->buf = last->buf_alloc;
|
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
|
/* smart HTTP response; validate that the service
|
||||||
* pkt-line matches our request.
|
* pkt-line matches our request.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user