emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add support for custom user agent strings in url.el


From: Vibhav Pant
Subject: Re: [PATCH] Add support for custom user agent strings in url.el
Date: Sun, 19 Jan 2014 15:15:43 +0530

Here's the fixed patch. I created a defcustom for the user-agent in url-http.el.

diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index ac2e140..6a0ec13 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -132,6 +132,15 @@ 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 '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 +223,7 @@ 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)))
+    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."



On Sun, Jan 19, 2014 at 2:42 PM, Bozhidar Batsov <address@hidden> wrote:
The default of the defcustom can also be the result of a function call (like `format', etc). Basically everything that returns a string will do. 


On 19 January 2014 10:36, Vibhav Pant <address@hidden> wrote:

Bozhidar Batsov writes:

> Seems to me that there should be just a defcustom `url-user-agent' and it
> should be used always. By default it should have whatever value it
> currently has and users will be able to customise it.
The function url-http-user-agent-string generates a user agent by
concatinating url-package-name and url-package-version. So the defcustom
would have to be a function or a sexp, making things a little confusing
for new users.

--
Vibhav Pant
address@hidden




--
Vibhav Pant
address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]