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>