From: Jo-Philipp Wich Date: Sat, 24 Nov 2018 18:54:07 +0000 (+0100) Subject: uclient-http: properly handle HTTP redirects via proxy connections X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3ba74ebc9363993ea2a83fd73b4c1b1a96e73940;p=oweals%2Fuclient.git uclient-http: properly handle HTTP redirects via proxy connections When uclient connects via an HTTP proxy connection we need to swap the contexts .proxy_url and not the .url property (which is the connection URL to the proxy server itself). This fixes uclient erroring out in a redirect loop when connecting via a proxy connection. Ref: https://forum.openwrt.org/t/opkg-update-fails/25813 Signed-off-by: Jo-Philipp Wich --- diff --git a/uclient-http.c b/uclient-http.c index 8d6d327..3168f4c 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -1174,8 +1174,15 @@ int uclient_http_redirect(struct uclient *cl) if (!url) return false; - free(cl->url); - cl->url = url; + if (cl->proxy_url) { + free(cl->proxy_url); + cl->proxy_url = url; + } + else { + free(cl->url); + cl->url = url; + } + if (uclient_http_connect(cl)) return -1;