Skip to content

Commit 49488cc

Browse files
committed
http: extract http_reauth_prepare() from retry paths
All three HTTP retry paths (http_request_recoverable, post_rpc, probe_rpc) call credential_fill() directly when handling HTTP_REAUTH. Extract this into a helper function so that a subsequent commit can add pre-fill logic (such as attempting empty-auth before prompting) in one place. No functional change. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
1 parent 2b39a27 commit 49488cc

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

http.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,11 @@ static void init_curl_http_auth(CURL *result)
665665
}
666666
}
667667

668+
void http_reauth_prepare(int all_capabilities)
669+
{
670+
credential_fill(the_repository, &http_auth, all_capabilities);
671+
}
672+
668673
/* *var must be free-able */
669674
static void var_override(char **var, char *value)
670675
{
@@ -2398,7 +2403,7 @@ static int http_request_recoverable(const char *url,
23982403
sleep(retry_delay);
23992404
}
24002405
} else if (ret == HTTP_REAUTH) {
2401-
credential_fill(the_repository, &http_auth, 1);
2406+
http_reauth_prepare(1);
24022407
}
24032408

24042409
ret = http_request(url, result, target, options);

http.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ extern int http_is_verbose;
7676
extern ssize_t http_post_buffer;
7777
extern struct credential http_auth;
7878

79+
/**
80+
* Prepare for an HTTP re-authentication retry. This fills credentials
81+
* via credential_fill() so the next request can include them.
82+
*/
83+
void http_reauth_prepare(int all_capabilities);
84+
7985
extern char curl_errorstr[CURL_ERROR_SIZE];
8086

8187
enum http_follow_config {

remote-curl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
946946
do {
947947
err = probe_rpc(rpc, &results);
948948
if (err == HTTP_REAUTH)
949-
credential_fill(the_repository, &http_auth, 0);
949+
http_reauth_prepare(0);
950950
} while (err == HTTP_REAUTH);
951951
if (err != HTTP_OK)
952952
return -1;
@@ -1068,7 +1068,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
10681068
rpc->any_written = 0;
10691069
err = run_slot(slot, NULL);
10701070
if (err == HTTP_REAUTH && !large_request) {
1071-
credential_fill(the_repository, &http_auth, 0);
1071+
http_reauth_prepare(0);
10721072
curl_slist_free_all(headers);
10731073
goto retry;
10741074
}

0 commit comments

Comments
 (0)