[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] http.c code cleaning
From: |
Dmitry Bogatov |
Subject: |
Re: [Bug-wget] http.c code cleaning |
Date: |
Thu, 09 May 2013 10:51:14 +0400 |
User-agent: |
mu4e 0.9.9.5; emacs 24.3.1 |
Giuseppe Scrivano <address@hidden> writes:
> Now you can assume opt.method is already uppercase as this is already
> enforced in cmd_string_uppercase (init.c).
>
> Please take a look at the commit 550457.
My bad. Here is fixed version.
>From dfb31c06db0ea98dfc8f08c20c8ec1de1f7ed0ca Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <address@hidden>
Date: Wed, 8 May 2013 18:10:55 +0400
Subject: [PATCH] Non-functionality improvement in src/http.c.
Pulled `request_set_method` functionality into `request_new`
to ensure these functions always called in right order.
---
src/http.c | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/src/http.c b/src/http.c
index 3a33840..6e5c481 100644
--- a/src/http.c
+++ b/src/http.c
@@ -147,27 +147,20 @@ struct request {
extern int numurls;
-/* Create a new, empty request. At least request_set_method must be
- called before the request can be used. */
+/* Create a new, empty request. Set the request's method and its
+ 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 *
-request_new (void)
+request_new (const char *method, char *arg)
{
struct request *req = xnew0 (struct request);
req->hcapacity = 8;
req->headers = xnew_array (struct request_header, req->hcapacity);
- return req;
-}
-
-/* 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->method = method;
req->arg = arg;
+ return req;
}
/* Return the method string passed with the last call to
@@ -1758,15 +1751,11 @@ gethttp (struct url *u, struct http_stat *hs, int *dt,
struct url *proxy,
conn = u;
/* Prepare the request to send. */
-
- req = request_new ();
{
char *meth_arg;
const char *meth = "GET";
if (head_only)
meth = "HEAD";
- else if (opt.method)
- meth = opt.method;
/* Use the full path, i.e. one that includes the leading slash and
the query string. E.g. if u->path is "foo/bar" and u->query is
"param=value", full_path will be "/foo/bar?param=value". */
@@ -1781,7 +1770,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt,
struct url *proxy,
meth_arg = xstrdup (u->url);
else
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);
@@ -2014,8 +2003,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt,
struct url *proxy,
{
/* When requesting SSL URLs through proxies, use the
CONNECT method to request passthrough. */
- struct request *connreq = request_new ();
- request_set_method (connreq, "CONNECT",
+ struct request *connreq = request_new ("CONNECT",
aprintf ("%s:%d", u->host, u->port));
SET_USER_AGENT (connreq);
if (proxyauth)
--
1.8.2.2
--
Best regards, Dmitry Bogatov <address@hidden>,
Free Software supporter and netiquette guardian.
git clone git://gitorious.org/illusionoflife-read-only/rc-files.git
--depth 1
GPG: 54B7F00D
Html mail and proprietary format attachments are forwarded to /dev/null.
- [Bug-wget] http.c code cleaning, Dmitry Bogatov, 2013/05/08
- Re: [Bug-wget] http.c code cleaning, Darshit Shah, 2013/05/08
- Re: [Bug-wget] http.c code cleaning, Giuseppe Scrivano, 2013/05/08
- Re: [Bug-wget] http.c code cleaning, Dmitry Bogatov, 2013/05/08
- Re: [Bug-wget] http.c code cleaning, Giuseppe Scrivano, 2013/05/08
- Re: [Bug-wget] http.c code cleaning,
Dmitry Bogatov <=
- Re: [Bug-wget] http.c code cleaning, Darshit Shah, 2013/05/09
- Re: [Bug-wget] http.c code cleaning, Dmitry Bogatov, 2013/05/10
- Re: [Bug-wget] http.c code cleaning, Giuseppe Scrivano, 2013/05/12