>From 0bc85a619677dc8a0313a5596497d42190fb3452 Mon Sep 17 00:00:00 2001 From: Matthew Atkinson 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 + + * 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 * 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