From owner-svn-src-all@FreeBSD.ORG Thu Jun 5 20:27:17 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 152CB73B; Thu, 5 Jun 2014 20:27:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 02DC525FD; Thu, 5 Jun 2014 20:27:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s55KRGaM064457; Thu, 5 Jun 2014 20:27:16 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s55KRGlA064455; Thu, 5 Jun 2014 20:27:16 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201406052027.s55KRGlA064455@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Thu, 5 Jun 2014 20:27:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267127 - head/lib/libfetch X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jun 2014 20:27:17 -0000 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@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");