Hi

I was looking through the list archives to find something that useful I could contribute to wget and get familiar with the code, I have attached a patch for the following.

Darshit Shah <darnir <at> gmail.com> wrote on 2014-09-05 07:31:34 GMT
>The Content-Length Header is expected by the server in many requests,
>most prominently in a POST Request. However, currently if a POST
>request is sent without any body, Wget does not send any
>Content-Length headers. Some servers seem to dislike this behaviour
>and respond with a 411 Length Required message.
>Patch Wget to always send a Content-Length header when the Request >Type is POST.

Hopefully I can find something less trivial to add or fix in the future, any suggestions, direction or feedback, please let me know.

Thanks,
Matt
diff --git a/src/http.c b/src/http.c
index 4b99c17..e020682 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1875,6 +1875,8 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
                               xstrdup (number_to_static_string (body_data_size)),
                               rel_value);
         }
+      else if (strcasecmp (opt.method, "post") == 0)
+        request_set_header (req, "Content-Length", "0", rel_none);
     }
 
  retry_with_auth:

Reply via email to