summaryrefslogtreecommitdiff
path: root/libfetch/ftp.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-01-19 16:37:39 +0200
committerTimo Teräs <timo.teras@iki.fi>2021-01-19 16:49:10 +0200
commitaa1f935c05129288f1550782e34d529fc77dda0a (patch)
tree1d1a7b8bde7bb608379f12b50585d37ebdb4bff0 /libfetch/ftp.c
parentc37b385beefd0e8324bf70f011e52a8c65f7fddf (diff)
downloadapk-tools-aa1f935c05129288f1550782e34d529fc77dda0a.tar.gz
apk-tools-aa1f935c05129288f1550782e34d529fc77dda0a.tar.bz2
apk-tools-aa1f935c05129288f1550782e34d529fc77dda0a.tar.xz
apk-tools-aa1f935c05129288f1550782e34d529fc77dda0a.zip
libfetch: fix connection pooling for proxied http/https requests
The connection pooling was broken in two ways: 1. The original URL was always used as the connection pool URL, resulting in duplicate connections to the proxy for http URLs (each http URL would get separate proxy connection) 2. The cache_url stored was always the socket level connect URL. In case of HTTPS, the lookup was done done with the real URL, but the proxy URL was stored as the "cache URL". Thus HTTPS CONNECT connections were never re-used. This fixes the code with following logic: 1. The cache key url is the real URL when no-proxy, or when HTTPS with proxy (the socket is connected to proxy, but logically it is connected to the real URL due to HTTP CONNECT request). And for HTTP with proxy, it's the proxy URL so same proxy connection can be reused for all requests going through it. 2. fetch_connect() now gets cache key URL separately, and it always gets the same value as the fetch_cache_get() calls.
Diffstat (limited to 'libfetch/ftp.c')
-rw-r--r--libfetch/ftp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libfetch/ftp.c b/libfetch/ftp.c
index 80f77d9..d489559 100644
--- a/libfetch/ftp.c
+++ b/libfetch/ftp.c
@@ -1020,7 +1020,7 @@ ftp_connect(struct url *url, struct url *purl, const char *flags)
if (!purl->port)
purl->port = fetch_default_port(purl->scheme);
- conn = fetch_connect(purl, af, verbose);
+ conn = fetch_connect(purl, purl, af, verbose);
} else {
/* no proxy, go straight to target */
if (!url->port)
@@ -1032,7 +1032,7 @@ ftp_connect(struct url *url, struct url *purl, const char *flags)
return conn;
fetch_close(conn);
}
- conn = fetch_connect(url, af, verbose);
+ conn = fetch_connect(url, url, af, verbose);
purl = NULL;
}