summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-05-25 16:09:27 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-05-25 16:09:27 +0000
commit6aefe176768350e3e65939bc802bdf7c90bfb320 (patch)
tree0a5d9e144f93bdc9cf6e27a8c680a12c823370a0 /usr.bin
parent8f8d1012e23d9c20f955c2359feb84cbf84b9b6e (diff)
do not attach incorrect Host: directive if we are using proxy.
Host: directive must be based on original URI, not the proxy address. see RFC2616.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ftp/fetch.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index 5ba2a89529c..6b887364eb8 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fetch.c,v 1.31 2000/05/15 16:07:04 itojun Exp $ */
+/* $OpenBSD: fetch.c,v 1.32 2000/05/25 16:09:26 itojun Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@@ -38,7 +38,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: fetch.c,v 1.31 2000/05/15 16:07:04 itojun Exp $";
+static char rcsid[] = "$OpenBSD: fetch.c,v 1.32 2000/05/25 16:09:26 itojun Exp $";
#endif /* not lint */
/*
@@ -346,23 +346,36 @@ again:
* Construct and send the request. We're expecting a return
* status of "200". Proxy requests don't want leading /.
*/
- if (verbose) {
- if (!proxy)
- fprintf(ttyout, "Requesting %s\n", origline);
- else
+ if (proxy) {
+ /*
+ * Host: directive must use the destination host address for
+ * the original URI (path). We do not attach it at this moment.
+ */
+ if (verbose)
fprintf(ttyout, "Requesting %s (via %s)\n",
origline, proxyenv);
- }
- if (strchr(host, ':')) {
- snprintf(buf, sizeof(buf),
- "GET %s%s HTTP/1.0\r\nHost: [%s]%s%s\r\n\r\n",
- proxy ? "" : "/", path, host,
- port ? ":" : "", port ? port : "");
+ snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n", path);
} else {
- snprintf(buf, sizeof(buf),
- "GET %s%s HTTP/1.0\r\nHost: %s%s%s\r\n\r\n",
- proxy ? "" : "/", path, host,
- port ? ":" : "", port ? port : "");
+ if (verbose)
+ fprintf(ttyout, "Requesting %s\n", origline);
+ if (strchr(host, ':')) {
+ char *h, *p;
+
+ /* strip off scoped address portion, since it's local to node */
+ h = strdup(host);
+ if (h == NULL)
+ errx(1, "Can't allocate memory.");
+ if ((p = strchr(h, '%')) != NULL)
+ *p = '\0';
+ snprintf(buf, sizeof(buf),
+ "GET /%s HTTP/1.0\r\nHost: [%s]%s%s\r\n\r\n",
+ path, h, port ? ":" : "", port ? port : "");
+ free(h);
+ } else {
+ snprintf(buf, sizeof(buf),
+ "GET /%s HTTP/1.0\r\nHost: %s%s%s\r\n\r\n",
+ path, host, port ? ":" : "", port ? port : "");
+ }
}
len = strlen(buf);
if (write(s, buf, len) < len) {