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");
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to