uclient-http: properly handle HTTP redirects via proxy connections
authorJo-Philipp Wich <jo@mein.io>
Sat, 24 Nov 2018 18:54:07 +0000 (19:54 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sat, 24 Nov 2018 18:54:07 +0000 (19:54 +0100)
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 <jo@mein.io>
uclient-http.c

index 8d6d32734ba93286c968212945a66a56fb781257..3168f4c6a58aa372c70587318e5cd80aa4f9c492 100644 (file)
@@ -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;