svn commit: r267127 - head/lib/libfetch
Dag-Erling Smørgrav
des at FreeBSD.org
Thu Jun 5 20:27:17 UTC 2014
Author: des
Date: Thu Jun 5 20:27:16 2014
New Revision: 267127
URL: http://svnweb.freebsd.org/changeset/base/267127
Log:
If HTTP_USER_AGENT is defined but empty, don't send User-Agent at all.
PR: 184507
Submitted by: jbeich at tormail.org (with modifications)
MFC after: 1 week
Modified:
head/lib/libfetch/fetch.3
head/lib/libfetch/http.c
Modified: head/lib/libfetch/fetch.3
==============================================================================
--- head/lib/libfetch/fetch.3 Thu Jun 5 19:38:44 2014 (r267126)
+++ head/lib/libfetch/fetch.3 Thu Jun 5 20:27:16 2014 (r267127)
@@ -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: head/lib/libfetch/http.c
==============================================================================
--- head/lib/libfetch/http.c Thu Jun 5 19:38:44 2014 (r267126)
+++ head/lib/libfetch/http.c Thu Jun 5 20:27:16 2014 (r267127)
@@ -1683,10 +1683,15 @@ http_request(struct url *URL, const char
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-all
mailing list