From d9f7c524b6a9d0e3c95a93c5122857c460ee3e37 Mon Sep 17 00:00:00 2001 From: Ted Zlatanov Date: Wed, 5 Nov 2014 11:06:40 -0500 Subject: [PATCH] url-http.el: introduce url-user-agent * url-http.el (url-user-agent): New variable, can be function or string. Suggested by Vibhav Pant . (url-http-user-agent-string): Use it. * url-http.el (url-user-agent): New variable, can be function or string. Suggested by Vibhav Pant . --- lisp/url/ChangeLog | 8 ++++++++ lisp/url/url-http.el | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index 12972ea04ab..b3b8057a9f9 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog @@ -1,3 +1,11 @@ +2014-11-05 Teodor Zlatanov + + * url-http.el (url-user-agent): New variable, can be function or + string. Suggested by Vibhav Pant . + (Bug#16498) + + (url-http-user-agent-string): Use it. + 2014-10-29 Paul Eggert Simplify use of current-time and friends. diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index f9fbea1ba74..7fbd5d0ae4c 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -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." -- 2.11.4.GIT