Code

grep documentation: clarify what files match
[git.git] / remote-curl.c
index 4f28c222f2064b27c41bbcfbb425c6a221b46a58..3edbf5717c94f3123a97939acf265cc8334ca899 100644 (file)
@@ -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.
                 */
@@ -307,7 +321,7 @@ static size_t rpc_out(void *ptr, size_t eltsize,
                rpc->len = avail;
        }
 
-       if (max < avail);
+       if (max < avail)
                avail = max;
        memcpy(ptr, rpc->buf + rpc->pos, avail);
        rpc->pos += avail;
@@ -356,8 +370,8 @@ static int post_rpc(struct rpc_state *rpc)
        slot = get_active_slot();
        slot->results = &results;
 
-       curl_easy_setopt(slot->curl, CURLOPT_POST, 1);
        curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
+       curl_easy_setopt(slot->curl, CURLOPT_POST, 1);
        curl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);
        curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "");
 
@@ -480,7 +494,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
        strbuf_addf(&buf, "Content-Type: application/x-%s-request", svc);
        rpc->hdr_content_type = strbuf_detach(&buf, NULL);
 
-       strbuf_addf(&buf, "Accept: application/x-%s-response", svc);
+       strbuf_addf(&buf, "Accept: application/x-%s-result", svc);
        rpc->hdr_accept = strbuf_detach(&buf, NULL);
 
        while (!err) {