Merge branch 'sp/maint-smart-http-sans-100-continue'
authorJunio C Hamano <gitster@pobox.com>
Mon, 14 Mar 2011 18:59:10 +0000 (11:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 14 Mar 2011 18:59:10 +0000 (11:59 -0700)
* sp/maint-smart-http-sans-100-continue:
smart-http: Really never use Expect: 100-continue

1  2 
remote-curl.c
diff --combined remote-curl.c
index d0fb0a044a85ec6169c4623c7c2ab2143dbb5784,1f41a90936e5865d94883f57887e7ce57b716f0f..775d6143037aa4573c0202715fe1b1a0f99e2799
@@@ -9,7 -9,8 +9,7 @@@
  #include "sideband.h"
  
  static struct remote *remote;
 -static const char *url;
 -static struct walker *walker;
 +static const char *url; /* always ends with a trailing slash */
  
  struct options {
        int verbosity;
  };
  static struct options options;
  
 -static void init_walker(void)
 -{
 -      if (!walker)
 -              walker = get_http_walker(url, remote);
 -}
 -
  static int set_option(const char *name, const char *value)
  {
        if (!strcmp(name, "verbosity")) {
@@@ -101,7 -108,7 +101,7 @@@ static struct discovery* discover_refs(
                return last;
        free_discovery(last);
  
 -      strbuf_addf(&buffer, "%s/info/refs", url);
 +      strbuf_addf(&buffer, "%sinfo/refs", url);
        if (!prefixcmp(url, "http://") || !prefixcmp(url, "https://")) {
                is_http = 1;
                if (!strchr(url, '?'))
        }
        refs_url = strbuf_detach(&buffer, NULL);
  
 -      init_walker();
        http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
  
        /* try again with "plain" url (no ? or & appended) */
                strbuf_reset(&buffer);
  
                proto_git_candidate = 0;
 -              strbuf_addf(&buffer, "%s/info/refs", url);
 +              strbuf_addf(&buffer, "%sinfo/refs", url);
                refs_url = strbuf_detach(&buffer, NULL);
  
                http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
        case HTTP_MISSING_TARGET:
                die("%s not found: did you run git update-server-info on the"
                    " server?", refs_url);
 +      case HTTP_NOAUTH:
 +              die("Authentication failed");
        default:
                http_error(refs_url, http_ret);
                die("HTTP request failed");
@@@ -244,8 -250,9 +244,8 @@@ static struct ref *parse_info_refs(stru
                i++;
        }
  
 -      init_walker();
        ref = alloc_ref("HEAD");
 -      if (!walker->fetch_ref(walker, ref) &&
 +      if (!http_fetch_ref(url, ref) &&
            !resolve_remote_symref(ref, refs)) {
                ref->next = refs;
                refs = ref;
@@@ -446,12 -453,12 +446,12 @@@ static int post_rpc(struct rpc_state *r
  
        headers = curl_slist_append(headers, rpc->hdr_content_type);
        headers = curl_slist_append(headers, rpc->hdr_accept);
+       headers = curl_slist_append(headers, "Expect:");
  
        if (large_request) {
                /* The request body is large and the size cannot be predicted.
                 * We must use chunked encoding to send it.
                 */
-               headers = curl_slist_append(headers, "Expect:");
                headers = curl_slist_append(headers, "Transfer-Encoding: chunked");
                rpc->initial_buffer = 1;
                curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);
@@@ -539,6 -546,7 +539,6 @@@ static int rpc_service(struct rpc_stat
        struct child_process client;
        int err = 0;
  
 -      init_walker();
        memset(&client, 0, sizeof(client));
        client.in = -1;
        client.out = -1;
        rpc->out = client.out;
        strbuf_init(&rpc->result, 0);
  
 -      strbuf_addf(&buf, "%s/%s", url, svc);
 +      strbuf_addf(&buf, "%s%s", url, svc);
        rpc->service_url = strbuf_detach(&buf, NULL);
  
        strbuf_addf(&buf, "Content-Type: application/x-%s-request", svc);
                rpc->len = n;
                err |= post_rpc(rpc);
        }
 -      strbuf_read(&rpc->result, client.out, 0);
  
        close(client.in);
 -      close(client.out);
        client.in = -1;
 +      strbuf_read(&rpc->result, client.out, 0);
 +
 +      close(client.out);
        client.out = -1;
  
        err |= finish_command(&client);
  
  static int fetch_dumb(int nr_heads, struct ref **to_fetch)
  {
 +      struct walker *walker;
        char **targets = xmalloc(nr_heads * sizeof(char*));
        int ret, i;
  
        for (i = 0; i < nr_heads; i++)
                targets[i] = xstrdup(sha1_to_hex(to_fetch[i]->old_sha1));
  
 -      init_walker();
 +      walker = get_http_walker(url);
        walker->get_all = 1;
        walker->get_tree = 1;
        walker->get_history = 1;
        walker->get_verbosely = options.verbosity >= 3;
        walker->get_recover = 0;
        ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);
 +      walker_free(walker);
  
        for (i = 0; i < nr_heads; i++)
                free(targets[i]);
@@@ -845,15 -850,11 +845,15 @@@ int main(int argc, const char **argv
        remote = remote_get(argv[1]);
  
        if (argc > 2) {
 -              url = argv[2];
 +              end_url_with_slash(&buf, argv[2]);
        } else {
 -              url = remote->url[0];
 +              end_url_with_slash(&buf, remote->url[0]);
        }
  
 +      url = strbuf_detach(&buf, NULL);
 +
 +      http_init(remote);
 +
        do {
                if (strbuf_getline(&buf, stdin, '\n') == EOF)
                        break;
                }
                strbuf_reset(&buf);
        } while (1);
 +
 +      http_cleanup();
 +
        return 0;
  }