svn commit: r270461 - stable/9/lib/libfetch
Dag-Erling Smørgrav
des at FreeBSD.org
Sun Aug 24 14:04:25 UTC 2014
Author: des
Date: Sun Aug 24 14:04:23 2014
New Revision: 270461
URL: http://svnweb.freebsd.org/changeset/base/270461
Log:
MFH (r267127): don't send User-Agent if HTTP_USER_AGENT is empty
Modified:
stable/9/lib/libfetch/fetch.3
stable/9/lib/libfetch/http.c
Directory Properties:
stable/9/lib/libfetch/ (props changed)
Modified: stable/9/lib/libfetch/fetch.3
==============================================================================
--- stable/9/lib/libfetch/fetch.3 Sun Aug 24 14:04:20 2014 (r270460)
+++ stable/9/lib/libfetch/fetch.3 Sun Aug 24 14:04:23 2014 (r270461)
@@ -627,6 +627,7 @@ the document URL will be used as referre
Specifies the User-Agent string to use for HTTP requests.
This can be useful when working with HTTP origin or proxy servers that
differentiate between user agents.
+If defined but empty, no User-Agent header is sent.
.It Ev NETRC
Specifies a file to use instead of
.Pa ~/.netrc
Modified: stable/9/lib/libfetch/http.c
==============================================================================
--- stable/9/lib/libfetch/http.c Sun Aug 24 14:04:20 2014 (r270460)
+++ stable/9/lib/libfetch/http.c Sun Aug 24 14:04:23 2014 (r270461)
@@ -1693,10 +1693,15 @@ http_request_body(struct url *URL, const
else
http_cmd(conn, "Referer: %s", p);
}
- if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0')
- http_cmd(conn, "User-Agent: %s", p);
- else
- http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER, getprogname());
+ if ((p = getenv("HTTP_USER_AGENT")) != NULL) {
+ /* no User-Agent if defined but empty */
+ if (*p != '\0')
+ http_cmd(conn, "User-Agent: %s", p);
+ } else {
+ /* default User-Agent */
+ http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER,
+ getprogname());
+ }
if (url->offset > 0)
http_cmd(conn, "Range: bytes=%lld-", (long long)url->offset);
http_cmd(conn, "Connection: close");
More information about the svn-src-stable-9
mailing list