From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vibhav Pant Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add support for custom user agent strings in url.el Date: Sun, 19 Jan 2014 15:15:43 +0530 Message-ID: References: <87k3dw5r44.fsf@cthulhu-p5kpl.lan> <87iotg5pw5.fsf@cthulhu-p5kpl.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1133148a8a1d9304f04fa35f X-Trace: ger.gmane.org 1390124745 909 80.91.229.3 (19 Jan 2014 09:45:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Jan 2014 09:45:45 +0000 (UTC) Cc: emacs-devel To: Bozhidar Batsov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 19 10:45:53 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W4owx-0005du-JA for ged-emacs-devel@m.gmane.org; Sun, 19 Jan 2014 10:45:51 +0100 Original-Received: from localhost ([::1]:45636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4owx-0003SO-1V for ged-emacs-devel@m.gmane.org; Sun, 19 Jan 2014 04:45:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4owt-0003SJ-37 for emacs-devel@gnu.org; Sun, 19 Jan 2014 04:45:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W4owr-0008UJ-QE for emacs-devel@gnu.org; Sun, 19 Jan 2014 04:45:47 -0500 Original-Received: from mail-pd0-x22a.google.com ([2607:f8b0:400e:c02::22a]:47593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4owr-0008U8-Co for emacs-devel@gnu.org; Sun, 19 Jan 2014 04:45:45 -0500 Original-Received: by mail-pd0-f170.google.com with SMTP id p10so1450798pdj.1 for ; Sun, 19 Jan 2014 01:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=7mENRXHrvArguZ4Synd80ddGYJ4GOiBqn5tvAFounaM=; b=CdvAwa3lWaTzhUWJioZEZYmfw8ucrV3P92qGl6oyMFitaAH5XkcfdZyqARd1HcCR4t SzndXrOhtkAW3neQr9fqXCTtAnMo2AMXpAbTFSmDDSnttkqGxvyEVVDHAflVca2NtPM3 no2UUIh4czw7aFehBUFi9IZuObHVDu1fYnku5fLwQ6JK6QQg0qa1pe+nT0hVZPPDAAKb RvOyvd0AoD4pSNIYOY6FuRoI5c3wu/8tLWeOhXK2b0rCqUsvfjqvc89P7rdEotqWbHTj 9zK3MFOOQb4+GdSPEhD1QiTvH7nq46HqyK7ejdtyh7iT5IJep+ZeawL0SQ7lLZDyEZfI Z5Uw== X-Received: by 10.66.132.69 with SMTP id os5mr12171580pab.114.1390124743661; Sun, 19 Jan 2014 01:45:43 -0800 (PST) Original-Received: by 10.70.70.231 with HTTP; Sun, 19 Jan 2014 01:45:43 -0800 (PST) In-Reply-To: X-Google-Sender-Auth: il18dGO-IL-ylwOWfmAlIjgDb_Y X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::22a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:168728 Archived-At: --001a1133148a8a1d9304f04fa35f Content-Type: text/plain; charset=ISO-8859-1 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 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 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 >> vibhavp@gmail.com >> > > -- Vibhav Pant vibhavp@gmail.com --001a1133148a8a1d9304f04fa35f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
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.")
=A0= =A0=A0=A0 (507 insufficient-storage=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "= Insufficient storage"))
=A0=A0 "The HTTP return codes and thei= r text.")
=A0
+(defcustom url-user-agent (format "User-Agen= t: %sURL/%s\r\n"
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 (if url-package-name
+=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 (concat url-package-name "/"
+=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 url-package-version " ")
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "") url-version)
+=A0 "Use= r Agent used by the URL package."
+=A0 :type 'string
+=A0 :g= roup 'url)
+
=A0;(eval-when-compile
=A0;; These are all macros= so that they are hidden from external sight
=A0;; when the file is byte-compiled.
@@ -214,11 +223,7 @@ request."= ;)
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (and (listp url-privacy-level)
=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (memq 'agent url-privacy-level)))<= br>=A0=A0=A0=A0=A0=A0 ""
-=A0=A0=A0 (format "User-Agent: = %sURL/%s\r\n"
-=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (if url-package-name
-=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 (concat url-package-name "/" url-package= -version " ")
-=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "&quo= t;)
-=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 url-version)))
+=A0=A0=A0 url-use= r-agent))
=A0
=A0(defun url-http-create-request (&optional ref-ur= l)
=A0=A0 "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 <bozhi= dar@batsov.com> wrote:
The default of the defcusto= m can also be the result of a function call (like `format', etc). Basic= ally everything that returns a string will do.=A0


=
On 19 January 2014 10:36, Vibhav Pant <vibhavp@gmail.com> wr= ote:

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
vibhavp@gmail.com




--
Vibhav Pant
--001a1133148a8a1d9304f04fa35f--