Skip to content

Commit 6e4b3e0

Browse files
[HttpClient] always send Content-Length when a body is passed
1 parent 375a315 commit 6e4b3e0

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
@@ -80,9 +80,11 @@ public function request(string $method, string $url, array $options = []): Respo
8080
}
8181
}
8282

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

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

0 commit comments

Comments
 (0)