On 20/10/14 21:16, Tim Rühsen wrote: > Since Wget does not explicitly support PUT, we may just care for the POST > request. Since servers may reject a POST without Content-Length, we are > better > off with supplying one. Since PUT (and also PATCH) request 'anticipate' a > body, > we could also care for these. > > Matthew, could you also check for 'put and 'patch' request and send an > amended > version of the patch. FYI, HTTP PATCH request is rfc5789.
Attached
>From 0bc85a619677dc8a0313a5596497d42190fb3452 Mon Sep 17 00:00:00 2001 From: Matthew Atkinson <[email protected]> Date: Tue, 21 Oct 2014 09:28:45 +0100 Subject: [PATCH] Always send Content-Length with POST, PUT, PATCH --- src/ChangeLog | 6 ++++++ src/http.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index d5aeca0..0f92db5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-10-21 Matthew Atkinson <[email protected]> + + * http.c (gethttp): Always send Content-Length header when method is POST, + PUT, or PATCH even with no post body, as some servers will reject the + request otherwise + 2014-10-16 Tim Ruehsen <[email protected]> * url.c (url_parse): little code cleanup diff --git a/src/http.c b/src/http.c index 4b99c17..2469852 100644 --- a/src/http.c +++ b/src/http.c @@ -1875,6 +1875,10 @@ 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 + || strcasecmp (opt.method, "put") == 0 + || strcasecmp (opt.method, "patch") == 0) + request_set_header (req, "Content-Length", "0", rel_none); } retry_with_auth: -- 1.9.1
