From d0d8e23c776e926b0e7e1b864d58c68ea0f9f9be Mon Sep 17 00:00:00 2001 From: Jacques ROUSSEL Date: Tue, 3 Oct 2023 08:02:05 +0200 Subject: [PATCH] Fix Content-Length for POST when data empty Signed-off-by: Jacques ROUSSEL --- src/Client.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Client.php b/src/Client.php index 2d144102..1525e836 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1256,6 +1256,12 @@ protected function prepareHeaders($body, $uri) $headers['Content-Length'] = strlen($body); } } + else { + if ($this->getMethod() == 'POST') { + $headers['Content-Length'] = 0; + } + } + // Merge the headers of the request (if any) // here we need right 'http field' and not lowercase letters