[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] [Wget-Bug][PATCH] Disable automatic wget headers
From: |
Darshit Shah |
Subject: |
Re: [Bug-wget] [Wget-Bug][PATCH] Disable automatic wget headers |
Date: |
Fri, 15 Mar 2019 11:18:54 +0100 |
User-agent: |
NeoMutt/20180716 |
Hi Afham,
Thanks for working on this bug. However, I am not convinced that this is the
best way of implementing this feature.
I would rather that we have a `--disable-header` switch which takes as input
the names of the headers that should be disabled. This way it is more flexible.
Simultaneously, it would be nice if you would also implement a parallel feature
in `--header` where the input of "header-name: " will cause <header-name> to
not be added to the request headers. This allows users to use the existing
`--header` switch as well.
Also, in the current implementation, I would prefer that you disabled the
generation of the header itself, rather than removing it at a later stage. That
is just inefficient.
* adham elkarn <address@hidden> [190315 10:26]:
> From: a-elk <address@hidden>
>
>
> Disable automatic wget headers.
>
> *options.h: added no-headers member
> *http.c: removed default headers
> *main.c: added new option noheaders, added help description
> *init.c: adde new option noheaders
>
> >From bug #54769 (https://savannah.gnu.org/bugs/?54769).
> Some servers doesn't handle well some headers. A --no-headers options will
> ensure a request will not include default
> defaut headers. This option disables default headers except Accept header and
> Host header
>
> Signed-off-by: Moises Torres, Adham El karn
> ---
> src/http.c | 8 ++++++++
> src/init.c | 1 +
> src/main.c | 3 +++
> src/options.h | 1 +
> 5 files changed, 14 insertions(+)
>
> diff --git a/src/http.c b/src/http.c
> index 304a2f86..e4bcbf27 100644
> --- a/src/http.c
> +++ b/src/http.c
> @@ -3259,6 +3259,14 @@ gethttp (const struct url *u, struct url
> *original_url, struct http_stat *hs,
> ),
> rel_value);
>
> + /* Remove default headers */
> + if (opt.no_headers)
> + {
> + int i;
> + for (i = 0; i < req->hcount; i++)
> + request_remove_header(req, req->headers[i].name);
> + }
> +
> /* Add the user headers. */
> if (opt.user_headers)
> {
> diff --git a/src/init.c b/src/init.c
> index 9b6665a6..ae2adeff 100644
> --- a/src/init.c
> +++ b/src/init.c
> @@ -262,6 +262,7 @@ static const struct {
> { "netrc", &opt.netrc, cmd_boolean },
> { "noclobber", &opt.noclobber, cmd_boolean },
> { "noconfig", &opt.noconfig, cmd_boolean },
> + { "noheaders", &opt.no_headers, cmd_boolean},
> { "noparent", &opt.no_parent, cmd_boolean },
> { "noproxy", &opt.no_proxy, cmd_vector },
> { "numtries", &opt.ntry, cmd_number_inf },/*
> deprecated*/
> diff --git a/src/main.c b/src/main.c
> index 65b7f3f3..92f87171 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -377,6 +377,7 @@ static struct cmdline_option option_data[] =
> { "no", 'n', OPT__NO, NULL, required_argument },
> { "no-clobber", 0, OPT_BOOLEAN, "noclobber", -1 },
> { "no-config", 0, OPT_BOOLEAN, "noconfig", -1},
> + { "no-headers", 0, OPT_BOOLEAN, "noheaders", no_argument},
> { "no-parent", 0, OPT_BOOLEAN, "noparent", -1 },
> { "output-document", 'O', OPT_VALUE, "outputdocument", -1 },
> { "output-file", 'o', OPT_VALUE, "logfile", -1 },
> @@ -1025,6 +1026,8 @@ Recursive accept/reject:\n"),
> -X, --exclude-directories=LIST list of excluded directories\n"),
> N_("\
> -np, --no-parent don't ascend to the parent directory\n"),
> + N_("\
> + --no-headers don't include default headers\n"),
> "\n",
> N_("Email bug reports, questions, discussions to <address@hidden>\n"),
> N_("and/or open issues at
> https://savannah.gnu.org/bugs/?func=additem&group=wget.\n")
> diff --git a/src/options.h b/src/options.h
> index 881e2b2e..65055ad8 100644
> --- a/src/options.h
> +++ b/src/options.h
> @@ -147,6 +147,7 @@ struct options
> char *http_user; /* HTTP username. */
> char *http_passwd; /* HTTP password. */
> char **user_headers; /* User-defined header(s). */
> + bool no_headers; /* Don'include default headers */
> bool http_keep_alive; /* whether we use keep-alive */
>
> bool use_proxy; /* Do we use proxy? */
> --
> 2.17.1
>
>
>
--
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6
signature.asc
Description: PGP signature