]> git.ipfire.org Git - thirdparty/git.git/blobdiff - remote-curl.c
http: hoist credential request out of handle_curl_result
[thirdparty/git.git] / remote-curl.c
index 5b3ce9eed299e312c132b590ea4926cfb019a271..8ffd7ff7a7189ce2022a49ef808b43024b04dcc2 100644 (file)
@@ -8,6 +8,7 @@
 #include "pkt-line.h"
 #include "sideband.h"
 #include "argv-array.h"
+#include "credential.h"
 
 static struct remote *remote;
 static const char *url; /* always ends with a trailing slash */
@@ -187,6 +188,7 @@ static struct discovery* discover_refs(const char *service, int for_push)
        struct discovery *last = last_discovery;
        char *refs_url;
        int http_ret, maybe_smart = 0;
+       struct http_get_options options;
 
        if (last && !strcmp(service, last->service))
                return last;
@@ -204,8 +206,12 @@ static struct discovery* discover_refs(const char *service, int for_push)
        }
        refs_url = strbuf_detach(&buffer, NULL);
 
-       http_ret = http_get_strbuf(refs_url, &type, &buffer,
-                                  HTTP_NO_CACHE | HTTP_KEEP_ERROR);
+       memset(&options, 0, sizeof(options));
+       options.content_type = &type;
+       options.no_cache = 1;
+       options.keep_error = 1;
+
+       http_ret = http_get_strbuf(refs_url, &buffer, &options);
        switch (http_ret) {
        case HTTP_OK:
                break;
@@ -444,6 +450,8 @@ static int post_rpc(struct rpc_state *rpc)
        if (large_request) {
                do {
                        err = probe_rpc(rpc);
+                       if (err == HTTP_REAUTH)
+                               credential_fill(&http_auth);
                } while (err == HTTP_REAUTH);
                if (err != HTTP_OK)
                        return -1;
@@ -543,8 +551,10 @@ retry:
        curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc);
 
        err = run_slot(slot);
-       if (err == HTTP_REAUTH && !large_request)
+       if (err == HTTP_REAUTH && !large_request) {
+               credential_fill(&http_auth);
                goto retry;
+       }
        if (err != HTTP_OK)
                err = -1;