If HTTP_USER_AGENT is defined but empty, don't send User-Agent at all.
PR: 184507 Submitted by: jbeich@tormail.org (with modifications) MFC after: 1 week
This commit is contained in:
parent
c835c70600
commit
c257f99e9b
@ -627,6 +627,7 @@ the document URL will be used as referrer URL.
|
||||
Specifies the User-Agent string to use for HTTP requests.
|
||||
This can be useful when working with HTTP origin or proxy servers that
|
||||
differentiate between user agents.
|
||||
If defined but empty, no User-Agent header is sent.
|
||||
.It Ev NETRC
|
||||
Specifies a file to use instead of
|
||||
.Pa ~/.netrc
|
||||
|
@ -1683,10 +1683,15 @@ http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
else
|
||||
http_cmd(conn, "Referer: %s", p);
|
||||
}
|
||||
if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0')
|
||||
http_cmd(conn, "User-Agent: %s", p);
|
||||
else
|
||||
http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER, getprogname());
|
||||
if ((p = getenv("HTTP_USER_AGENT")) != NULL) {
|
||||
/* no User-Agent if defined but empty */
|
||||
if (*p != '\0')
|
||||
http_cmd(conn, "User-Agent: %s", p);
|
||||
} else {
|
||||
/* default User-Agent */
|
||||
http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER,
|
||||
getprogname());
|
||||
}
|
||||
if (url->offset > 0)
|
||||
http_cmd(conn, "Range: bytes=%lld-", (long long)url->offset);
|
||||
http_cmd(conn, "Connection: close");
|
||||
|
Loading…
Reference in New Issue
Block a user