Skip to content

Commit bf21a2f

Browse files
authored
Stop using HttpResponse::stream method (#1947)
1 parent 5b8e35c commit bf21a2f

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

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

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
.EXPORT_ALL_VARIABLES:
22

33
initialize: start-docker
4-
start-docker:
4+
start-docker: start-docker-s3 start-docker-localstack
5+
start-docker-localstack:
56
docker start async_aws_localstack && exit 0 || \
67
docker start async_aws_localstack-sts && exit 0 || \
78
docker pull localstack/localstack:3.0.0 && \
89
docker run -d -p 4566:4566 -e SERVICES=sts -v /var/run/docker.sock:/var/run/docker.sock --name async_aws_localstack-sts localstack/localstack:3.0.0 && \
910
docker run --rm --link async_aws_localstack-sts:localstack martin/wait -c localstack:4566
11+
start-docker-s3:
12+
docker pull asyncaws/testing-s3
13+
docker start async_aws_s3 && exit 0 || \
14+
docker run -d -p 4569:4569 -p 4570:4569 --name async_aws_s3 asyncaws/testing-s3
1015

1116
test: initialize
1217
./vendor/bin/simple-phpunit

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
}

tests/Integration/ClientTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AsyncAws\Core\Tests\Integration;
6+
7+
use AsyncAws\Core\Credentials\NullProvider;
8+
use AsyncAws\S3\S3Client;
9+
use PHPUnit\Framework\TestCase;
10+
11+
class ClientTest extends TestCase
12+
{
13+
public function testStreamToStream(): void
14+
{
15+
if (!class_exists(S3Client::class)) {
16+
self::markTestSkipped('This test needs a client with waiter endpoints');
17+
}
18+
19+
$client = new S3Client([
20+
'endpoint' => 'http://localhost:4569',
21+
'pathStyleEndpoint' => true,
22+
], new NullProvider());
23+
24+
$client->createBucket(['Bucket' => 'foo'])->resolve();
25+
$client->putObject([
26+
'Bucket' => 'foo',
27+
'Key' => 'bar',
28+
'Body' => 'content',
29+
])->resolve();
30+
31+
$client->putObject([
32+
'Bucket' => 'foo',
33+
'Key' => 'bar2',
34+
'Body' => $client->getObject(['Bucket' => 'foo', 'Key' => 'bar'])->getBody()->getContentAsResource(),
35+
])->resolve();
36+
37+
self::expectNotToPerformAssertions();
38+
}
39+
}

0 commit comments

Comments
 (0)