mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Factor out some proxy initialization code for gethttp
* src/http.c (gethttp): Move some initialization code in... (initialize_proxy_configuration): ... a new function.
This commit is contained in:
parent
29850e77d0
commit
f8abb9dd00
63
src/http.c
63
src/http.c
@ -1778,6 +1778,38 @@ initialize_request (struct url *u, struct http_stat *hs, int *dt, struct url *pr
|
|||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
initialize_proxy_configuration (struct url *u, struct request *req,
|
||||||
|
struct url *proxy, char **proxyauth)
|
||||||
|
{
|
||||||
|
char *proxy_user, *proxy_passwd;
|
||||||
|
/* For normal username and password, URL components override
|
||||||
|
command-line/wgetrc parameters. With proxy
|
||||||
|
authentication, it's the reverse, because proxy URLs are
|
||||||
|
normally the "permanent" ones, so command-line args
|
||||||
|
should take precedence. */
|
||||||
|
if (opt.proxy_user && opt.proxy_passwd)
|
||||||
|
{
|
||||||
|
proxy_user = opt.proxy_user;
|
||||||
|
proxy_passwd = opt.proxy_passwd;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
proxy_user = proxy->user;
|
||||||
|
proxy_passwd = proxy->passwd;
|
||||||
|
}
|
||||||
|
/* #### This does not appear right. Can't the proxy request,
|
||||||
|
say, `Digest' authentication? */
|
||||||
|
if (proxy_user && proxy_passwd)
|
||||||
|
*proxyauth = basic_authentication_encode (proxy_user, proxy_passwd);
|
||||||
|
|
||||||
|
/* Proxy authorization over SSL is handled below. */
|
||||||
|
#ifdef HAVE_SSL
|
||||||
|
if (u->scheme != SCHEME_HTTPS)
|
||||||
|
#endif
|
||||||
|
request_set_header (req, "Proxy-Authorization", *proxyauth, rel_value);
|
||||||
|
}
|
||||||
|
|
||||||
/* Retrieve a document through HTTP protocol. It recognizes status
|
/* Retrieve a document through HTTP protocol. It recognizes status
|
||||||
code, and correctly handles redirections. It closes the network
|
code, and correctly handles redirections. It closes the network
|
||||||
socket. If it receives an error from the functions below it, it
|
socket. If it receives an error from the functions below it, it
|
||||||
@ -1917,38 +1949,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
|||||||
proxyauth = NULL;
|
proxyauth = NULL;
|
||||||
if (proxy)
|
if (proxy)
|
||||||
{
|
{
|
||||||
char *proxy_user, *proxy_passwd;
|
|
||||||
/* For normal username and password, URL components override
|
|
||||||
command-line/wgetrc parameters. With proxy
|
|
||||||
authentication, it's the reverse, because proxy URLs are
|
|
||||||
normally the "permanent" ones, so command-line args
|
|
||||||
should take precedence. */
|
|
||||||
if (opt.proxy_user && opt.proxy_passwd)
|
|
||||||
{
|
|
||||||
proxy_user = opt.proxy_user;
|
|
||||||
proxy_passwd = opt.proxy_passwd;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
proxy_user = proxy->user;
|
|
||||||
proxy_passwd = proxy->passwd;
|
|
||||||
}
|
|
||||||
/* #### This does not appear right. Can't the proxy request,
|
|
||||||
say, `Digest' authentication? */
|
|
||||||
if (proxy_user && proxy_passwd)
|
|
||||||
proxyauth = basic_authentication_encode (proxy_user, proxy_passwd);
|
|
||||||
|
|
||||||
/* If we're using a proxy, we will be connecting to the proxy
|
|
||||||
server. */
|
|
||||||
conn = proxy;
|
conn = proxy;
|
||||||
|
initialize_proxy_configuration (u, req, proxy, &proxyauth);
|
||||||
/* Proxy authorization over SSL is handled below. */
|
|
||||||
#ifdef HAVE_SSL
|
|
||||||
if (u->scheme != SCHEME_HTTPS)
|
|
||||||
#endif
|
|
||||||
request_set_header (req, "Proxy-Authorization", proxyauth, rel_value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_alive = true;
|
keep_alive = true;
|
||||||
|
|
||||||
/* Establish the connection. */
|
/* Establish the connection. */
|
||||||
|
Loading…
Reference in New Issue
Block a user