Date: Sun, 24 Aug 2014 14:04:20 +0000 (UTC) From: Dag-Erling Smørgrav <des@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r270460 - stable/10/lib/libfetch Message-ID: <201408241404.s7OE4K20026253@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: des Date: Sun Aug 24 14:04:20 2014 New Revision: 270460 URL: http://svnweb.freebsd.org/changeset/base/270460 Log: MFH (r267127): don't send User-Agent if HTTP_USER_AGENT is empty Modified: stable/10/lib/libfetch/fetch.3 stable/10/lib/libfetch/http.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libfetch/fetch.3 ============================================================================== --- stable/10/lib/libfetch/fetch.3 Sun Aug 24 14:00:44 2014 (r270459) +++ stable/10/lib/libfetch/fetch.3 Sun Aug 24 14:04:20 2014 (r270460) @@ -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/10/lib/libfetch/http.c ============================================================================== --- stable/10/lib/libfetch/http.c Sun Aug 24 14:00:44 2014 (r270459) +++ stable/10/lib/libfetch/http.c Sun Aug 24 14:04:20 2014 (r270460) @@ -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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408241404.s7OE4K20026253>