unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Bozhidar Batsov <bozhidar@batsov.com>
To: Vibhav Pant <vibhavp@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: [PATCH] Add support for custom user agent strings in url.el
Date: Sun, 19 Jan 2014 10:15:41 +0200	[thread overview]
Message-ID: <CAM9Zgm0aSws3q-334eR5mRak_-LMeDXY_Lkb5WsAmr06VUPmXA@mail.gmail.com> (raw)
In-Reply-To: <87k3dw5r44.fsf@cthulhu-p5kpl.lan>

[-- Attachment #1: Type: text/plain, Size: 2953 bytes --]

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.


On 19 January 2014 10:10, Vibhav Pant <vibhavp@gmail.com> wrote:

> -----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-----
>
>

[-- Attachment #2: Type: text/html, Size: 3750 bytes --]

  reply	other threads:[~2014-01-19  8:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM9Zgm0aSws3q-334eR5mRak_-LMeDXY_Lkb5WsAmr06VUPmXA@mail.gmail.com \
    --to=bozhidar@batsov.com \
    --cc=emacs-devel@gnu.org \
    --cc=vibhavp@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).