Skip to content

Commit e02a151

Browse files
CI runs \o/ (but still red)
1 parent 845bf31 commit e02a151

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
class AmpBody implements HttpContent, ReadableStream, \IteratorAggregate
2828
{
2929
private ReadableStream $body;
30+
private ?string $content;
3031
private array $info;
3132
private ?int $offset = 0;
3233
private int $length = -1;
@@ -49,6 +50,7 @@ public function __construct(
4950
} elseif (\is_string($body)) {
5051
$this->length = \strlen($body);
5152
$this->body = new ReadableBuffer($body);
53+
$this->content = $body;
5254
} else {
5355
$this->body = new ReadableIterableStream((static function () use ($body) {
5456
while ('' !== $data = ($body)(16372)) {
@@ -135,14 +137,12 @@ public static function rewind(HttpContent $body): HttpContent
135137

136138
$body->uploaded = null;
137139

138-
if ($body->body instanceof ReadableResourceStream) {
140+
if ($body->body instanceof ReadableResourceStream && !$body->body->isClosed()) {
139141
fseek($body->body->getResource(), $body->offset);
140-
141-
return new $body($body->body->getResource(), $body->info, $body->onProgress);
142142
}
143143

144144
if ($body->body instanceof ReadableBuffer) {
145-
return new $body($body->body->read(), $body->info, $body->onProgress);
145+
return new $body($body->content, $body->info, $body->onProgress);
146146
}
147147

148148
return $body;

src/Symfony/Component/HttpClient/Response/AmpResponse.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function __construct(
108108

109109
$this->canary = new Canary(static function () use ($canceller, $multi, $id) {
110110
$canceller->cancel();
111+
$multi->openHandles[$id]?->isComplete() || $multi->openHandles[$id]->complete();
111112
unset($multi->openHandles[$id], $multi->handlesActivity[$id]);
112113
});
113114

@@ -134,7 +135,7 @@ public function __wakeup(): void
134135
public function __destruct()
135136
{
136137
try {
137-
$this->doDestruct();
138+
//$this->doDestruct();
138139
} finally {
139140
// Clear the DNS cache when all requests completed
140141
if (0 >= --$this->multi->responseCount) {
@@ -262,8 +263,6 @@ private static function generateResponse(Request $request, AmpClientState $multi
262263
} finally {
263264
$info['download_content_length'] = $info['size_download'];
264265
}
265-
266-
$multi->openHandles[$id]->complete();
267266
}
268267

269268
private static function followRedirects(Request $originRequest, AmpClientState $multi, array &$info, array &$headers, DeferredCancellation $canceller, array $options, \Closure $onProgress, &$handle, ?LoggerInterface $logger, float &$pause): ?Response

0 commit comments

Comments
 (0)