]> git.eshelyaron.com Git - emacs.git/commitdiff
url-http.el: introduce url-user-agent
authorTed Zlatanov <tzz@lifelogs.com>
Wed, 5 Nov 2014 16:06:40 +0000 (11:06 -0500)
committerTed Zlatanov <tzz@lifelogs.com>
Wed, 5 Nov 2014 16:06:40 +0000 (11:06 -0500)
* url-http.el (url-user-agent): New variable, can be function or
string.  Suggested by Vibhav Pant <vibhavp@ubuntu.com>.

(url-http-user-agent-string): Use it.

* url-http.el (url-user-agent): New variable, can be function or
string.  Suggested by Vibhav Pant <vibhavp@ubuntu.com>.

lisp/url/ChangeLog
lisp/url/url-http.el

index 12972ea04aba34034e367a240b3e5f99d58dfde2..b3b8057a9f98061b82e64144591b69df39e01eec 100644 (file)
@@ -1,3 +1,11 @@
+2014-11-05  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * url-http.el (url-user-agent): New variable, can be function or
+       string.  Suggested by Vibhav Pant <vibhavp@ubuntu.com>.
+       (Bug#16498)
+
+       (url-http-user-agent-string): Use it.
+
 2014-10-29  Paul Eggert  <eggert@cs.ucla.edu>
 
        Simplify use of current-time and friends.
index f9fbea1ba743e2884f6f3de011d47336021d76e2..7fbd5d0ae4cf16e8c1b03958705959a802f9621b 100644 (file)
@@ -132,6 +132,16 @@ request.")
     (507 insufficient-storage            "Insufficient storage"))
   "The HTTP return codes and their text.")
 
+(defcustom url-user-agent (format "User-Agent: %sURL/%s\r\n"
+                                 (if url-package-name
+                                     (concat url-package-name "/"
+                                             url-package-version " ")
+                                   "") url-version)
+  "User Agent used by the URL package."
+  :type '(choice (string :tag "A static User-Agent string")
+                 (function :tag "Call a function to get the User-Agent string"))
+  :group 'url)
+
 ;(eval-when-compile
 ;; These are all macros so that they are hidden from external sight
 ;; when the file is byte-compiled.
@@ -214,11 +224,9 @@ request.")
          (and (listp url-privacy-level)
               (memq 'agent url-privacy-level)))
       ""
-    (format "User-Agent: %sURL/%s\r\n"
-           (if url-package-name
-               (concat url-package-name "/" url-package-version " ")
-             "")
-           url-version)))
+    (if (functionp url-user-agent)
+        (funcall url-user-agent)
+      url-user-agent)))
 
 (defun url-http-create-request (&optional ref-url)
   "Create an HTTP request for `url-http-target-url', referred to by REF-URL."