Skip to content

Commit 58f3f98

Browse files
committed
Merge branch 'jk/maint-http-init-not-in-result-handler'
Further clean-up to the http codepath that picks up results after cURL library is done with one request slot. * jk/maint-http-init-not-in-result-handler: http: do not set up curl auth after a 401 remote-curl: do not call run_slot repeatedly
2 parents d2f4469 + 1960897 commit 58f3f98

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

http.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,7 @@ char *get_remote_object_url(const char *url, const char *hex,
745745
return strbuf_detach(&buf, NULL);
746746
}
747747

748-
int handle_curl_result(struct active_request_slot *slot,
749-
struct slot_results *results)
748+
int handle_curl_result(struct slot_results *results)
750749
{
751750
if (results->curl_result == CURLE_OK) {
752751
credential_approve(&http_auth);
@@ -759,7 +758,6 @@ int handle_curl_result(struct active_request_slot *slot,
759758
return HTTP_NOAUTH;
760759
} else {
761760
credential_fill(&http_auth);
762-
init_curl_http_auth(slot->curl);
763761
return HTTP_REAUTH;
764762
}
765763
} else {
@@ -821,7 +819,7 @@ static int http_request(const char *url, void *result, int target, int options)
821819

822820
if (start_active_slot(slot)) {
823821
run_active_slot(slot);
824-
ret = handle_curl_result(slot, &results);
822+
ret = handle_curl_result(&results);
825823
} else {
826824
error("Unable to start HTTP request for %s", url);
827825
ret = HTTP_START_FAILED;

http.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ extern int start_active_slot(struct active_request_slot *slot);
7878
extern void run_active_slot(struct active_request_slot *slot);
7979
extern void finish_active_slot(struct active_request_slot *slot);
8080
extern void finish_all_active_slots(void);
81-
extern int handle_curl_result(struct active_request_slot *slot,
82-
struct slot_results *results);
81+
extern int handle_curl_result(struct slot_results *results);
8382

8483
#ifdef USE_CURL_MULTI
8584
extern void fill_active_slots(void);

remote-curl.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static int run_slot(struct active_request_slot *slot)
356356
slot->curl_result = curl_easy_perform(slot->curl);
357357
finish_active_slot(slot);
358358

359-
err = handle_curl_result(slot, &results);
359+
err = handle_curl_result(&results);
360360
if (err != HTTP_OK && err != HTTP_REAUTH) {
361361
error("RPC failed; result=%d, HTTP code = %ld",
362362
results.curl_result, results.http_code);
@@ -431,17 +431,18 @@ static int post_rpc(struct rpc_state *rpc)
431431
return -1;
432432
}
433433

434+
headers = curl_slist_append(headers, rpc->hdr_content_type);
435+
headers = curl_slist_append(headers, rpc->hdr_accept);
436+
headers = curl_slist_append(headers, "Expect:");
437+
438+
retry:
434439
slot = get_active_slot();
435440

436441
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
437442
curl_easy_setopt(slot->curl, CURLOPT_POST, 1);
438443
curl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);
439444
curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "gzip");
440445

441-
headers = curl_slist_append(headers, rpc->hdr_content_type);
442-
headers = curl_slist_append(headers, rpc->hdr_accept);
443-
headers = curl_slist_append(headers, "Expect:");
444-
445446
if (large_request) {
446447
/* The request body is large and the size cannot be predicted.
447448
* We must use chunked encoding to send it.
@@ -515,9 +516,9 @@ static int post_rpc(struct rpc_state *rpc)
515516
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
516517
curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc);
517518

518-
do {
519-
err = run_slot(slot);
520-
} while (err == HTTP_REAUTH && !large_request && !use_gzip);
519+
err = run_slot(slot);
520+
if (err == HTTP_REAUTH && !large_request && !use_gzip)
521+
goto retry;
521522
if (err != HTTP_OK)
522523
err = -1;
523524

0 commit comments

Comments
 (0)