diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2020-02-22 01:00:08 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2020-02-22 01:00:08 +0000 |
commit | 421c7840391f82baa4432a43fa480a5737177565 (patch) | |
tree | 3c3e3fa8579c81a74f437ee66c35a3575c262199 /usr.bin/ftp/fetch.c | |
parent | 58ad709a830b02002faaba32eb8caaba9e9541b7 (diff) |
Avoid duplication in the code that sends headers
ok yasuoka@
Diffstat (limited to 'usr.bin/ftp/fetch.c')
-rw-r--r-- | usr.bin/ftp/fetch.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 57c237a50e3..f69ed702140 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.193 2020/02/22 00:58:28 jca Exp $ */ +/* $OpenBSD: fetch.c,v 1.194 2020/02/22 01:00:07 jca Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -730,19 +730,10 @@ noslash: restart_point = 0; } #endif /* SMALL */ - if (credentials) { - ftp_printf(fin, - "GET /%s HTTP/1.1\r\n" - "Connection: close\r\n" - "Authorization: Basic %s\r\n" - "Host: ", epath, credentials); - free(credentials); - credentials = NULL; - } else - ftp_printf(fin, - "GET /%s HTTP/1.1\r\n" - "Connection: close\r\n" - "Host: ", epath); + ftp_printf(fin, + "GET /%s HTTP/1.1\r\n" + "Connection: close\r\n" + "Host: ", epath); if (proxyhost) { ftp_printf(fin, "%s", proxyhost); port = NULL; @@ -776,8 +767,12 @@ noslash: if (port && strcmp(port, "80") != 0) ftp_printf(fin, ":%s", port); #endif /* !NOSSL */ - ftp_printf(fin, "\r\n%s%s\r\n\r\n", + ftp_printf(fin, "\r\n%s%s\r\n", buf ? buf : "", httpuseragent); + if (credentials) + ftp_printf(fin, "Authorization: Basic %s\r\n", + credentials); + ftp_printf(fin, "\r\n"); } free(epath); |