Date: Sun, 24 Aug 2014 14:04:24 +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-9@freebsd.org Subject: svn commit: r270461 - stable/9/lib/libfetch Message-ID: <201408241404.s7OE4ORp026306@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408241404.s7OE4ORp026306>