Skip to content

Commit 5aa31b2

Browse files
committed
Ignore RuntimeExceptions thrown in Psr18Client and HttplugClient when rewinding streams
1 parent e3a3370 commit 5aa31b2

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
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/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)