Move uclient_http_process_headers() into the deferred callback so that
auth_type is captured before it gets updated. The previous refactor in
commit
80c9bd29c233 ("uclient-http: fix hang on HTTP to HTTPS redirect")
moved the auth_type snapshot after uclient_http_process_headers() had
already changed it from AUTH_TYPE_UNKNOWN, causing the 401 retry path
to never trigger.
Fixes: https://github.com/openwrt/uclient/issues/14
Signed-off-by: Felix Fietkau <nbd@nbd.name>
enum auth_type auth_type = uh->auth_type;
unsigned int seq = uh->seq;
+ uclient_http_process_headers(uh);
+
if (auth_type == AUTH_TYPE_UNKNOWN && uh->uc.status_code == 401 &&
(uh->req_type == REQ_HEAD || uh->req_type == REQ_GET)) {
uclient_http_connect(&uh->uc);
{
uh->state = HTTP_STATE_PROCESS_HEADERS;
uh->uc.meta = uh->meta.head;
- uclient_http_process_headers(uh);
uh->process_headers_t.cb = uclient_http_process_headers_cb;
uloop_timeout_set(&uh->process_headers_t, 1);