bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] [Wget-Bug][PATCH] Disable automatic wget headers


From: adham elkarn
Subject: [Bug-wget] [Wget-Bug][PATCH] Disable automatic wget headers
Date: Thu, 14 Mar 2019 21:12:19 +0000

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]