diff options
| author | Mike Barcroft <mike@FreeBSD.org> | 2001-08-30 00:57:35 +0000 |
|---|---|---|
| committer | Mike Barcroft <mike@FreeBSD.org> | 2001-08-30 00:57:35 +0000 |
| commit | 8bd14b98d04366f9fb1eb2b65dd696f4c345608d (patch) | |
| tree | ad64b2dc377aad3bb1823a48ab4250d5223c1695 /usr.bin | |
| parent | 3ca509eaca52cc74ba940f3cf01ae331c5583326 (diff) | |
Notes
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/ftp/fetch.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index f833f01f5a08..cce524d50f2b 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -104,7 +104,7 @@ url_get(origline, proxyenv) char *port; volatile int s; size_t len; - char c, *cp, *ep, *portnum, *path, buf[4096]; + char c, *cp, *ep, *http_buffer, *portnum, *path, buf[4096]; const char *savefile; char *line, *proxy, *host; volatile sig_t oldintr; @@ -276,20 +276,25 @@ url_get(origline, proxyenv) * Construct and send the request. We're expecting a return * status of "200". Proxy requests don't want leading /. */ - if (!proxy) + if (!proxy) { printf("Requesting %s\n", origline); - else + len = asprintf(&http_buffer, + "GET /%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", path, host); + } else { printf("Requesting %s (via %s)\n", origline, proxyenv); - len = snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", - proxy ? "" : "/", path); - if (len < 0 || len >= sizeof(buf)) { + len = asprintf(&http_buffer, + "GET %s HTTP/1.0\r\n\r\n", path); + } + if (len < 0) { warnx("Failed to format HTTP request"); goto cleanup_url_get; } - if (write(s, buf, len) < len) { + if (write(s, http_buffer, len) < len) { warn("Writing HTTP request"); + free(http_buffer); goto cleanup_url_get; } + free(http_buffer); memset(buf, 0, sizeof(buf)); for (cp = buf; cp < buf + sizeof(buf); ) { if (read(s, cp, 1) != 1) |
