Skip to content

Commit 74dc4d2

Browse files
KurtThiemannnicolas-grekas
authored andcommitted
[HttpClient] Ignore RuntimeExceptions thrown when rewinding the PSR-7 created in HttplugWaitLoop::createPsr7Response
1 parent e46482c commit 74dc4d2

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/Symfony/Component/HttpClient/HttplugClient.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ public function createStream($content = ''): StreamInterface
202202
}
203203

204204
if ($stream->isSeekable()) {
205-
$stream->seek(0);
205+
try {
206+
$stream->seek(0);
207+
} catch (\RuntimeException) {
208+
// ignore
209+
}
206210
}
207211

208212
return $stream;
@@ -274,7 +278,11 @@ private function sendPsr7Request(RequestInterface $request, ?bool $buffer = null
274278
$body = $request->getBody();
275279

276280
if ($body->isSeekable()) {
277-
$body->seek(0);
281+
try {
282+
$body->seek(0);
283+
} catch (\RuntimeException) {
284+
// ignore
285+
}
278286
}
279287

280288
$options = [

src/Symfony/Component/HttpClient/Internal/HttplugWaitLoop.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ public static function createPsr7Response(ResponseFactoryInterface $responseFact
145145
}
146146

147147
if ($body->isSeekable()) {
148-
$body->seek(0);
148+
try {
149+
$body->seek(0);
150+
} catch (\RuntimeException) {
151+
// ignore
152+
}
149153
}
150154

151155
return $psrResponse->withBody($body);

src/Symfony/Component/HttpClient/Psr18Client.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ public function sendRequest(RequestInterface $request): ResponseInterface
9090
$body = $request->getBody();
9191

9292
if ($body->isSeekable()) {
93-
$body->seek(0);
93+
try {
94+
$body->seek(0);
95+
} catch (\RuntimeException) {
96+
// ignore
97+
}
9498
}
9599

96100
$options = [
@@ -136,7 +140,11 @@ public function createStream(string $content = ''): StreamInterface
136140
$stream = $this->streamFactory->createStream($content);
137141

138142
if ($stream->isSeekable()) {
139-
$stream->seek(0);
143+
try {
144+
$stream->seek(0);
145+
} catch (\RuntimeException) {
146+
// ignore
147+
}
140148
}
141149

142150
return $stream;

0 commit comments

Comments
 (0)