[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Changing a user agent string
On 2018-01-18 10:29, Katsumi Yamaoka wrote:
> In [emacs-w3m:12876]
> On Wed, 17 Jan 2018 12:09:23 -0500, Boruch Baum wrote:
> > Attached is the patch.
> Thanks. I verified it works fine.
It's not showing up when I perform a `cvs update'.
> > 1] The feature is currently implemented only for `w3m-reload-this-page',
> > but shouldn't it somehow also implemented for `w3m-goto-url',
> > `w3m-goto-url-new-session', and maybe even `w3m-reload-all'pages'?
> Well, there might be a web site that is unable to open unless
> sending a fake user-agent (that's why IE calles itself Mozilla).
> So, not only `w3m-reload-this-page' but also the other commands
> would have to support the feature as you say.
I've been thinking some more about this. The original rationale for the
idea `C-u C-u R` was to give a user a quick and easy way to change a
user-agent string in order to see how a single page renders differently.
That makes sense for the command that reloads a single page. For the
other commands, which are more of a use-case of normal web browsing, I
think its reasonable to ask the user to call the function interactively
to change the user-agent string 'permanently', because it's just as easy
for the user to revert the change - I hard-coded one of the entries in
the `completing-read' collection to be the user's default user-agent
string and even labeled it that way. The end result is more
user-friendly than exists by default in any other browser with which I'm
> In addition, such a page might require the user-agent faking for
> also visiting links in it. In such a case, the user-agent value
> will need to be semi-permanent. I mean making it session-local,
> but if impossible buffer-local. Oh, that might only be able to
> make the code dirty.
Both ideas sound reasonable, for the reason you mention.
I'm not sure of everything that might be entailed to properly support
`session-local' user-agent strings. I suspect it would not be messy, but
it would need research, and at the very least would need to modify the
data structure and functions that save and restore session data.
OTOH, setting the variable as `buffer-local' seems straightforward. The
function, when called directly interactively would prompt the user to
choose whether to apply the setting globally, or just for the current
buffer. If you're certain you want that, let me know.
> Another idea is to introduce an alist that holds a list of a url-
> regexp and a user-agent pairs. It overrides the default user-agent
> if a regexp matches the url to visit.
This is a very nice idea. A complexity would be that there would need to
be a way to manually over-ride the alist ...
> > 3] When looking at item #2, I came across `w3m-add-referer'. Do I
> > understand correctly that the default always suppresses referers when
> > using https? Now that the project is encouraging https as a default,
> > should that behavior continue?
> Oh, I believe it should send a refer to https sites as well by
For me, the current value of `w3m-add-referer` is:
("\\`http:" . "\\`http://\\(?:localhost\\|127\\.0\\.0\\.1\\)/")
The change would be?
("\\`https?:" . "\\`https?://\\(?:localhost\\|127\\.0\\.0\\.1\\)/")
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0