mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Non-functionality improvement in src/http.c.
Pulled `request_set_method` functionality into `request_new` to ensure these functions always called in right order.
This commit is contained in:
parent
83837b0606
commit
027d9f385d
28
src/http.c
28
src/http.c
@ -147,27 +147,20 @@ struct request {
|
|||||||
|
|
||||||
extern int numurls;
|
extern int numurls;
|
||||||
|
|
||||||
/* Create a new, empty request. At least request_set_method must be
|
/* Create a new, empty request. Set the request's method and its
|
||||||
called before the request can be used. */
|
arguments. METHOD should be a literal string (or it should outlive
|
||||||
|
the request) because it will not be freed. ARG will be freed by
|
||||||
|
request_free. */
|
||||||
|
|
||||||
static struct request *
|
static struct request *
|
||||||
request_new (void)
|
request_new (const char *method, char *arg)
|
||||||
{
|
{
|
||||||
struct request *req = xnew0 (struct request);
|
struct request *req = xnew0 (struct request);
|
||||||
req->hcapacity = 8;
|
req->hcapacity = 8;
|
||||||
req->headers = xnew_array (struct request_header, req->hcapacity);
|
req->headers = xnew_array (struct request_header, req->hcapacity);
|
||||||
return req;
|
req->method = method;
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the request's method and its arguments. METH should be a
|
|
||||||
literal string (or it should outlive the request) because it will
|
|
||||||
not be freed. ARG will be freed by request_free. */
|
|
||||||
|
|
||||||
static void
|
|
||||||
request_set_method (struct request *req, const char *meth, char *arg)
|
|
||||||
{
|
|
||||||
req->method = meth;
|
|
||||||
req->arg = arg;
|
req->arg = arg;
|
||||||
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the method string passed with the last call to
|
/* Return the method string passed with the last call to
|
||||||
@ -1758,8 +1751,6 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
|||||||
conn = u;
|
conn = u;
|
||||||
|
|
||||||
/* Prepare the request to send. */
|
/* Prepare the request to send. */
|
||||||
|
|
||||||
req = request_new ();
|
|
||||||
{
|
{
|
||||||
char *meth_arg;
|
char *meth_arg;
|
||||||
const char *meth = "GET";
|
const char *meth = "GET";
|
||||||
@ -1781,7 +1772,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
|||||||
meth_arg = xstrdup (u->url);
|
meth_arg = xstrdup (u->url);
|
||||||
else
|
else
|
||||||
meth_arg = url_full_path (u);
|
meth_arg = url_full_path (u);
|
||||||
request_set_method (req, meth, meth_arg);
|
req = request_new (meth, meth_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
request_set_header (req, "Referer", (char *) hs->referer, rel_none);
|
request_set_header (req, "Referer", (char *) hs->referer, rel_none);
|
||||||
@ -2014,8 +2005,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
|||||||
{
|
{
|
||||||
/* When requesting SSL URLs through proxies, use the
|
/* When requesting SSL URLs through proxies, use the
|
||||||
CONNECT method to request passthrough. */
|
CONNECT method to request passthrough. */
|
||||||
struct request *connreq = request_new ();
|
struct request *connreq = request_new ("CONNECT",
|
||||||
request_set_method (connreq, "CONNECT",
|
|
||||||
aprintf ("%s:%d", u->host, u->port));
|
aprintf ("%s:%d", u->host, u->port));
|
||||||
SET_USER_AGENT (connreq);
|
SET_USER_AGENT (connreq);
|
||||||
if (proxyauth)
|
if (proxyauth)
|
||||||
|
Loading…
Reference in New Issue
Block a user