uclient-http: fix hang on HTTP to HTTPS redirect
authorFelix Fietkau <nbd@nbd.name>
Sat, 31 Jan 2026 13:45:38 +0000 (14:45 +0100)
committerFelix Fietkau <nbd@nbd.name>
Sat, 31 Jan 2026 13:54:29 +0000 (14:54 +0100)
commit80c9bd29c2331f34e91ec47fd7b486f58613a224
treedaeff73040ef96dc8612c5d6ed3d0f4907f63205
parent9c2ad269c42bca917fc563c97c732d8c47fd1bfc
uclient-http: fix hang on HTTP to HTTPS redirect

Defer header processing to a uloop timeout to avoid modifying stream
state while inside its callback chain. When switching protocols during
a redirect, the old stream's callback code could corrupt the new SSL
stream's state due to the union memory sharing between ustream_fd and
ustream_ssl.

Add HTTP_STATE_PROCESS_HEADERS intermediate state to prevent body data
from being processed before the deferred header_done callback runs.
Also detect protocol changes (HTTP to HTTPS) in uclient_http_connect()
to force a proper disconnect and reconnect.

Fixes: https://github.com/openwrt/uclient/issues/13
Signed-off-by: Felix Fietkau <nbd@nbd.name>
uclient-http.c