emacs-devel
[Top][All Lists]
Advanced

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

Help understanding the URL code


From: Clément Pit--Claudel
Subject: Help understanding the URL code
Date: Tue, 5 Apr 2016 16:37:22 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

Hi emacs-devel,

I'm looking into producing a patch to make it easier to customize the 
user-agent string that URL uses, but I'm hitting a number of walls. For 
example, what does this piece of code achieve?

    (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 for HTTP/HTTPS requests
    Should be a string or a function of no arguments returning a string."
      :type '(choice (string :tag "A static User-Agent string")
                     (function :tag "Call a function to get the User-Agent 
string"))
      :version "25.1"
      :group 'url)

This defcustom is evaluated the first time that url-vars.el is loaded, right? 
In that case, what's the point of the url-package-name and url-package-version 
variables? It seems that rebinding them won't ever do anything, since the 
definition is evaluated once and for all. Thus IIUC this bit of code will 
return different values depending on whether the url package had already been 
loaded before or whether it was loaded through url-retrieve-synchronously being 
autoloaded. Is that right?

    (let ((url-package-name "MyPackage"))
      (url-retrieve-synchronously "http://example.com";)
      url-user-agent)

If that's correct, then the attached (draft) patch might help in fixing this 
issue.

I would also welcome help on other issues, such as #23140 (about being unable 
to let-bind url-mime-accept-string). Am I missing something in how these new 
parts of url.el are supposed to be used? 

Clément.

Attachment: user-agent.patch
Description: Text Data

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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