10000 ensure existing content-length headers are not overwritten and ignore… · symfony/symfony@5ed994b · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ed994b

Browse files
committed
ensure existing content-length headers are not overwritten and ignore negative results from stream getSize in HttplugClient and Psr18Client
1 parent 25e3f12 commit 5ed994b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/HttpClient/HttplugClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ private function sendPsr7Request(RequestInterface $request, ?bool $buffer = null
230230
}
231231

232232
$headers = $request->getHeaders();
233-
if (($size = $body->getSize()) !== null) {
233+
if (!$request->hasHeader('content-length') && 0 <= $size = $body->getSize() ?? -1) {
234234
$headers['Content-Length'] = [$size];
235235
}
236236

src/Symfony/Component/HttpClient/Psr18Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function sendRequest(RequestInterface $request): ResponseInterface
9494
}
9595

9696
$headers = $request->getHeaders();
97-
if (($size = $body->getSize()) !== null) {
97+
if (!$request->hasHeader('content-length') && 0 <= $size = $body->getSize() ?? -1) {
9898
$headers['Content-Length'] = [$size];
9999
}
100100

0 commit comments

Comments
 (0)
0