Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit508d605

Browse files
ajgarlagnicolas-grekas
authored andcommitted
Prevent empty request body stream in HttplugClient and Psr18Client
This prevents adding `Content-Length` and `Transfer-Encoding` headerswhen sending a request with an empty body using CurlHttpClient
1 parentf0239d8 commit508d605

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

‎src/Symfony/Component/HttpClient/HttplugClient.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ private function sendPsr7Request(RequestInterface $request, ?bool $buffer = null
231231
$headers['Content-Length'] = [$size];
232232
}
233233

234-
if (0 <=$size &&$size <1 <<21) {
234+
if (0 ===$size) {
235+
$body ='';
236+
}elseif (0 <$size &&$size <1 <<21) {
235237
if ($body->isSeekable()) {
236238
try {
237239
$body->seek(0);

‎src/Symfony/Component/HttpClient/Psr18Client.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ public function sendRequest(RequestInterface $request): ResponseInterface
9191
$headers =$request->getHeaders();
9292

9393
$size =$request->getHeader('content-length')[0] ?? -1;
94-
if (0 >$size &&0 <=$size =$body->getSize() ?? -1) {
94+
if (0 >$size &&0 <$size =$body->getSize() ?? -1) {
9595
$headers['Content-Length'] = [$size];
9696
}
9797

98-
if (0 <=$size &&$size <1 <<21) {
98+
if (0 ===$size) {
99+
$body ='';
100+
}elseif (0 <$size &&$size <1 <<21) {
99101
if ($body->isSeekable()) {
100102
try {
101103
$body->seek(0);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp