Skip to content

Commit 97c9be2

Browse files
CI runs \o/ (but still red)
1 parent 78e03c0 commit 97c9be2

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 \Closure $onProgress;
3233
private ?int $offset = 0;
@@ -48,6 +49,7 @@ public function __construct($body, &$info, \Closure $onProgress)
4849
} elseif (\is_string($body)) {
4950
$this->length = \strlen($body);
5051
$this->body = new ReadableBuffer($body);
52+
$this->content = $body;
5153
} else {
5254
$this->body = new ReadableIterableStream((static function () use ($body) {
5355
while ('' !== $data = ($body)(16372)) {
@@ -134,14 +136,12 @@ public static function rewind(HttpContent $body): HttpContent
134136

135137
$body->uploaded = null;
136138

137-
if ($body->body instanceof ReadableResourceStream) {
139+
if ($body->body instanceof ReadableResourceStream && !$body->body->isClosed()) {
138140
fseek($body->body->getResource(), $body->offset);
139-
140-
return new $body($body->body->getResource(), $body->info, $body->onProgress);
141141
}
142142

143143
if ($body->body instanceof ReadableBuffer) {
144-
return new $body($body->body->read(), $body->info, $body->onProgress);
144+
return new $body($body->content, $body->info, $body->onProgress);
145145
}
146146

147147
return $body;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function __construct(AmpClientState $multi, Request $request, array $opti
106106

107107
$this->canary = new Canary(static function () use ($canceller, $multi, $id) {
108108
$canceller->cancel();
109+
$multi->openHandles[$id]?->isComplete() || $multi->openHandles[$id]->complete();
109110
unset($multi->openHandles[$id], $multi->handlesActivity[$id]);
110111
});
111112

@@ -132,7 +133,7 @@ public function __wakeup()
132133
public function __destruct()
133134
{
134135
try {
135-
$this->doDestruct();
136+
//$this->doDestruct();
136137
} finally {
137138
// Clear the DNS cache when all requests completed
138139
if (0 >= --$this->multi->responseCount) {
@@ -260,8 +261,6 @@ private static function generateResponse(Request $request, AmpClientState $multi
260261
} finally {
261262
$info['download_content_length'] = $info['size_download'];
262263
}
263-
264-
$multi->openHandles[$id]->complete();
265264
}
266265

267266
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)