Skip to content

Commit 0361dc9

Browse files
committed
Stop using HttpResponse::stream method
1 parent 2f6755b commit 0361dc9

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

src/Core/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
## NOT RELEASED
44

5+
### Fixed
6+
7+
- Buffer the response in temporary file to avoid issues when stream is used by another request's body
8+
59
## 1.27.1
610

711
### Fixed
812

9-
- SignerV4: fix sort of query parameters to build correct canoncal query string
13+
- SignerV4: fix sort of query parameters to build correct canoncal query string
1014

1115
## 1.27.0
1216

src/Core/src/Response.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use AsyncAws\Core\Exception\LogicException;
1818
use AsyncAws\Core\Exception\RuntimeException;
1919
use AsyncAws\Core\Exception\UnparsableResponse;
20-
use AsyncAws\Core\Stream\ResponseBodyResourceStream;
2120
use AsyncAws\Core\Stream\ResponseBodyStream;
2221
use AsyncAws\Core\Stream\ResultStream;
2322
use Psr\Log\LoggerInterface;
@@ -288,7 +287,7 @@ final public static function wait(iterable $responses, ?float $timeout = null, b
288287
* @return array{
289288
* resolved: bool,
290289
* body_downloaded: bool,
291-
* response: \Symfony\Contracts\HttpClient\ResponseInterface,
290+
* response: ResponseInterface,
292291
* status: int,
293292
* }
294293
*/
@@ -369,10 +368,6 @@ public function toStream(): ResultStream
369368
{
370369
$this->resolve();
371370

372-
if (\is_callable([$this->httpResponse, 'toStream'])) {
373-
return new ResponseBodyResourceStream($this->httpResponse->toStream());
374-
}
375-
376371
if ($this->streamStarted) {
377372
throw new RuntimeException('Can not create a ResultStream because the body started being downloaded. The body was started to be downloaded in Response::wait()');
378373
}

src/Service/S3/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- AWS api-change: Expires's property and its getters/setters switched from `\DateTimeImmutable` to `string`.
88

9+
### Changed
10+
11+
- Add test to ensure a response's body can be streamed to another request's body.
12+
913
## 2.10.0
1014

1115
### Added

src/Service/S3/tests/Integration/S3ClientTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,25 @@ public function testUploadPartCopy(): void
10081008
self::assertEquals(200, $result->info()['status']);
10091009
}
10101010

1011+
public function testStreamToStream(): void
1012+
{
1013+
$client = $this->getClient();
1014+
1015+
$client->putObject([
1016+
'Bucket' => 'foo',
1017+
'Key' => 'bar',
1018+
'Body' => 'content',
1019+
])->resolve();
1020+
1021+
$client->putObject([
1022+
'Bucket' => 'foo',
1023+
'Key' => 'bar2',
1024+
'Body' => $client->getObject(['Bucket' => 'foo', 'Key' => 'bar'])->getBody()->getContentAsResource(),
1025+
])->resolve();
1026+
1027+
self::expectNotToPerformAssertions();
1028+
}
1029+
10111030
private function getClient(): S3Client
10121031
{
10131032
return new S3Client([

0 commit comments

Comments
 (0)