Skip to content

Commit 3f35854

Browse files
Merge branch '4.4' into 5.4
* 4.4: [HttpClient] always send Content-Length when a body is passed
2 parents f06092c + 6e4b3e0 commit 3f35854

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

NativeHttpClient.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ public function request(string $method, string $url, array $options = []): Respo
8181
}
8282
}
8383

84+
$sendContentLength = !\is_string($options['body']) || 'POST' === $method;
85+
8486
$options['body'] = self::getBodyAsString($options['body']);
8587

86-
if ('' === $options['body'] && 'POST' === $method && !isset($options['normalized_headers']['content-length'])) {
88+
if ('' === $options['body'] && $sendContentLength && !isset($options['normalized_headers']['content-length'])) {
8789
$options['headers'][] = 'Content-Length: 0';
8890
}
8991
if (('' !== $options['body'] || 'POST' === $method) && !isset($options['normalized_headers']['content-type'])) {

0 commit comments

Comments
 (0)