diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-11-24 19:54:07 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-11-24 19:54:07 +0100 |
commit | 3ba74ebc9363993ea2a83fd73b4c1b1a96e73940 (patch) | |
tree | b68b3fee8416527e200e0f10b5d213ba70378596 | |
parent | ae1c656ff041c6f1ccb37b070fa261e0d71f2b12 (diff) | |
download | uclient-3ba74ebc9363993ea2a83fd73b4c1b1a96e73940.tar.gz |
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 <jo@mein.io>
-rw-r--r-- | uclient-http.c | 11 |
1 files 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; |