Unverified Commit b0509cee authored by Tatsuya Kinoshita's avatar Tatsuya Kinoshita Committed by GitHub

Merge pull request #113 from spk/allow-override-user-agent

Allow to override UserAgent
parents 599f5c17 b06d1f6a
......@@ -935,6 +935,7 @@ global int w3m_dump init(0);
global int w3m_halfload init(FALSE);
global Str header_string init(NULL);
global int override_content_type init(FALSE);
global int override_user_agent init(FALSE);
#ifdef USE_COLOR
global int useColor init(TRUE);
......
......@@ -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 */
......
......@@ -1324,12 +1324,14 @@ otherinfo(ParsedURL *target, ParsedURL *current, char *referer)
const int *no_referer_ptr;
int no_referer;
Strcat_charp(s, "User-Agent: ");
if (UserAgent == NULL || *UserAgent == '\0')
Strcat_charp(s, w3m_version);
else
Strcat_charp(s, UserAgent);
Strcat_charp(s, "\r\n");
if (!override_user_agent) {
Strcat_charp(s, "User-Agent: ");
if (UserAgent == NULL || *UserAgent == '\0')
Strcat_charp(s, w3m_version);
else
Strcat_charp(s, UserAgent);
Strcat_charp(s, "\r\n");
}
Strcat_m_charp(s, "Accept: ", AcceptMedia, "\r\n", NULL);
Strcat_m_charp(s, "Accept-Encoding: ", AcceptEncoding, "\r\n", NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment