From 3ba74ebc9363993ea2a83fd73b4c1b1a96e73940 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 24 Nov 2018 19:54:07 +0100 Subject: [PATCH] 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 --- uclient-http.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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; -- 2.30.2