From b06d1f6a02dee2b26696b5f910877f0409b0266c Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Sun, 21 Apr 2019 21:47:38 +0200 Subject: Allow to override UserAgent 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 --- main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index 43e181c..7bb058e 100644 --- a/main.c +++ b/main.c @@ -375,6 +375,8 @@ make_optional_header_string(char *s) Strcopy_charp_n(hs, s, p - s); if (!Strcasecmp_charp(hs, "content-type")) override_content_type = TRUE; + if (!Strcasecmp_charp(hs, "user-agent")) + override_user_agent = TRUE; Strcat_charp(hs, ": "); if (*(++p)) { /* not null header */ SKIP_BLANKS(p); /* skip white spaces */ -- cgit v1.2.3