unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Add support for custom user agent strings in url.el
@ 2014-01-19  8:10 Vibhav Pant
  2014-01-19  8:15 ` Bozhidar Batsov
  0 siblings, 1 reply; 13+ messages in thread
From: Vibhav Pant @ 2014-01-19  8:10 UTC (permalink / raw)
  To: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

I added support to url.el for a custom user agent string by defining a
variable url-custom-user-agent which contains a user-defined string. The
variable is nil by default, in which case the function
url-http-user-agent-string reutrns the default user agent.
(Patch was created on a git repository)

diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index ac2e140..1b63a25 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -214,11 +214,15 @@ 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 url-custom-user-agent
+       (format "User-Agent: %s\n" url-custom-user-agent)
+      
+      (format "User-Agent: %sURL/%s\r\n"
+             (if url-package-name
+                 (concat url-package-name "/" url-package-version " ")
+               "")
+             url-version))))
 
 (defun url-http-create-request (&optional ref-url)
   "Create an HTTP request for `url-http-target-url', referred to by REF-URL."
diff --git a/lisp/url/url.el b/lisp/url/url.el
index cbbcfd4..c54a94e 100644
--- a/lisp/url/url.el
+++ b/lisp/url/url.el
@@ -51,6 +51,10 @@
   :type 'directory
   :group 'url)
 
+(defvar url-custom-user-agent nil
+  "User Agent used by url-http-create-request to fetch pages. If nil,
+the default user agent will be used.")
+
 (defun url-do-setup ()
   "Setup the URL package.
 This is to avoid conflict with user settings if URL is dumped with

- -- 
Vibhav Pant
vibhavp@gmail.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBCgAGBQJS24fqAAoJEO86onTybWtcUdkP/2s5MGg3/zY/Xg8KmSxAU20x
Ki0UamZHp5xNgr6UcN0SIseVGTTMBfJrwWL70LnslvvzRcPysRK0v+sOL4PjNcsT
nkOU8BjsTt4HMFi48LPqhr+OacAFrMVT0E3vo0rtYoQSSw7tNgEprLUr3i2Yc1vY
II23YllVdIqb6Ys6arYuMb5V5vP83GfnV9hm1jNSt3TGefSMsgDVggBRiw7NBk8Q
pJqZ14rblX68V+b2cmw8JAzDkq7mWZ+s6CU/Ic4KI3a37k3kvoDwXwU8kCMVpP7Q
aBK9VzSLlDzzLD+TZI7I7K5n6dA4He4BwwhFgQuUwOmoI5nF3W7y1gSOCL4sBOLF
5tqlRZFR+RJUDGabV6PoSux2K61sYegMN0NzzyrUCTPwqb9ISMNBfGfL0lp/QFuh
ENxHmTnyO/J+FTIFAQ4Dbv4RYn5xxivgPp4UmYG3vin7b3E/+2jsOKdeQO/V5iBA
85XUKEdxH5JUergw0A9rsBvWkRw/iy89+edqg1hNJkWD8sSY+4H3QXGly63mQzdc
51QWCwAJ1ShPif8RI9yD1Eyvctoasv+WM42NakCZ7bDUOwuHqJfAAEVbQeg9ijn9
EynM7n5CmAAap6vrjdeNWJvxPWPXv32UHSsstOAN7MPgd9Cw6gZvfYY4DITHqWbe
BykRZe2zqv4iIlgL87Rg
=8VAL
-----END PGP SIGNATURE-----



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-01-20 14:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-19  8:10 [PATCH] Add support for custom user agent strings in url.el Vibhav Pant
2014-01-19  8:15 ` Bozhidar Batsov
2014-01-19  8:36   ` Vibhav Pant
2014-01-19  9:12     ` Bozhidar Batsov
2014-01-19  9:45       ` Vibhav Pant
2014-01-19  9:58         ` Vibhav Pant
2014-01-19 14:13           ` Vibhav Pant
2014-01-20  9:13           ` Richard Stallman
2014-01-20 12:11             ` Rüdiger Sonderfeld
2014-01-20 12:13           ` Rüdiger Sonderfeld
2014-01-20 14:03             ` Vibhav Pant
2014-01-19 14:42         ` Stefan Monnier
2014-01-19 15:28           ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).