Skip to content

Commit 90765ea

Browse files
bk2204gitster
authored andcommitted
remote-curl: reset headers on new request
When we retry a post_rpc request, we currently reuse the same headers as before. In the future, we'd like to be able to modify them based on the result we get back, so let's reset them on each retry so we can avoid sending potentially duplicate headers if the values change. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7046f1d commit 90765ea

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

remote-curl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ static curl_off_t xcurl_off_t(size_t len)
893893
static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_received)
894894
{
895895
struct active_request_slot *slot;
896-
struct curl_slist *headers = http_copy_default_headers();
896+
struct curl_slist *headers = NULL;
897897
int use_gzip = rpc->gzip_request;
898898
char *gzip_body = NULL;
899899
size_t gzip_size = 0;
@@ -935,6 +935,8 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
935935
needs_100_continue = 1;
936936
}
937937

938+
retry:
939+
headers = http_copy_default_headers();
938940
headers = curl_slist_append(headers, rpc->hdr_content_type);
939941
headers = curl_slist_append(headers, rpc->hdr_accept);
940942
headers = curl_slist_append(headers, needs_100_continue ?
@@ -948,7 +950,6 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
948950
if (rpc->protocol_header)
949951
headers = curl_slist_append(headers, rpc->protocol_header);
950952

951-
retry:
952953
slot = get_active_slot();
953954

954955
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
@@ -1044,6 +1045,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
10441045
err = run_slot(slot, NULL);
10451046
if (err == HTTP_REAUTH && !large_request) {
10461047
credential_fill(&http_auth);
1048+
curl_slist_free_all(headers);
10471049
goto retry;
10481050
}
10491051
if (err != HTTP_OK)

0 commit comments

Comments
 (0)