Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to override UserAgent #113

Merged
merged 1 commit into from
Apr 22, 2019
Merged

Conversation

spk
Copy link
Contributor

@spk spk commented Apr 21, 2019

Hello,

Adding on command line the user agent add a duplicate header:

./w3m -header "User-Agent: Mozilla" http://localhost:9999

GET / HTTP/1.0
User-Agent: w3m/0.5.3+git20190105
Accept: text/html, text/*;q=0.5, image/*, application/*, message/*, x-scheme-handler/*, audio/*, video/*, inode/*
Accept-Encoding: gzip, compress, bzip, bzip2, deflate
Accept-Language: en;q=1.0
Host: localhost:9999
User-Agent: Mozilla

As a result most server will take the first given; the default
w3m_version or the one defined on config user_agent

With this patch we can now override User-Agent from command line

Cheers,
Laurent

Adding on command line the user agent add a duplicate header:

```
./w3m -header "User-Agent: Mozilla" http://localhost:9999

GET / HTTP/1.0
User-Agent: w3m/0.5.3+git20190105
Accept: text/html, text/*;q=0.5, image/*, application/*, message/*, x-scheme-handler/*, audio/*, video/*, inode/*
Accept-Encoding: gzip, compress, bzip, bzip2, deflate
Accept-Language: en;q=1.0
Host: localhost:9999
Pragma: no-cache
Cache-control: no-cache
User-Agent: Mozilla
```

As a result most server will take the first given; the default
w3m_version or the one defined on config `user_agent`

With this patch we can now override `User-Agent` from command line
@tats
Copy link
Owner

tats commented Apr 22, 2019

w3m_version or the one defined on config user_agent
With this patch we can now override User-Agent from command line

The config value can be set by -o from command line,
e.g. w3m -o user_agent=Mozilla.

@spk
Copy link
Contributor Author

spk commented Apr 22, 2019

The config value can be set by -o from command line,
e.g. w3m -o user_agent=Mozilla.

Cool thanks for the info, but don't you find its a strange behavior ? I've checked with curl that have the same config/header options and you can override the user agent with:

curl --header "User-Agent: w3m" localhost:9999

GET / HTTP/1.1
Host: localhost:9999
Accept: */*
Referer:
User-Agent: w3m

@tats tats merged commit b0509ce into tats:master Apr 22, 2019
@tats
Copy link
Owner

tats commented Apr 22, 2019

Anyway, preventing User-Agent twice is reasonable.

Merged, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants