summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2005-08-09 03:32:29 +0000
committercperciva <cperciva@FreeBSD.org>2005-08-09 03:32:29 +0000
commitb7fa3f9b224a934beee4bb790f287c8d0c9d1ca8 (patch)
tree163d3b03ac3af45bd0911787f8d929f6cf7aac94
parent98677d0cbe01a5d4581c6cc392bf3b353d9053d1 (diff)
downloadFreeBSD-src-b7fa3f9b224a934beee4bb790f287c8d0c9d1ca8.zip
FreeBSD-src-b7fa3f9b224a934beee4bb790f287c8d0c9d1ca8.tar.gz
When parsing the HTTP_PROXY environment variable, strip a trailing /
from the port number (if any exists). This unbreaks env HTTP_PROXY="http://localhost:3128/" portsnap fetch While I'm here, list both the host and the port in the error message output if getaddrinfo() fails, since either of them could be responsible for the failure.
-rw-r--r--usr.sbin/portsnap/phttpget/phttpget.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/portsnap/phttpget/phttpget.c b/usr.sbin/portsnap/phttpget/phttpget.c
index a75c6ea..a68f60f 100644
--- a/usr.sbin/portsnap/phttpget/phttpget.c
+++ b/usr.sbin/portsnap/phttpget/phttpget.c
@@ -66,6 +66,9 @@ readenv(void)
if (env_HTTP_PROXY) {
if (strncmp(env_HTTP_PROXY, "http://", 7) == 0)
env_HTTP_PROXY += 7;
+ p = strchr(env_HTTP_PROXY, '/');
+ if (p != NULL)
+ *p = 0;
p = strchr(env_HTTP_PROXY, ':');
if (p != NULL) {
*p = 0;
@@ -223,8 +226,9 @@ main(int argc, char *argv[])
error = getaddrinfo(env_HTTP_PROXY ? env_HTTP_PROXY : servername,
env_HTTP_PROXY ? proxyport : "http", &hints, &res0);
if (error)
- errx(1, "%s: %s",
+ errx(1, "%s: host = %s, port = %s",
env_HTTP_PROXY ? env_HTTP_PROXY : servername,
+ env_HTTP_PROXY ? proxyport : "http",
gai_strerror(error));
if (res0 == NULL)
errx(1, "could not look up %s", servername);
OpenPOWER on IntegriCloud