Crypto
11 months ago
Exception
11 months ago
RegionalEndpoint
11 months ago
UseArnRegion
11 months ago
AmbiguousSuccessParser.php
11 months ago
ApplyChecksumMiddleware.php
11 months ago
BatchDelete.php
11 months ago
BucketEndpointArnMiddleware.php
11 months ago
BucketEndpointMiddleware.php
11 months ago
CalculatesChecksumTrait.php
11 months ago
EndpointRegionHelperTrait.php
11 months ago
GetBucketLocationParser.php
11 months ago
MultipartCopy.php
11 months ago
MultipartUploader.php
11 months ago
MultipartUploadingTrait.php
11 months ago
ObjectCopier.php
11 months ago
ObjectUploader.php
11 months ago
PermanentRedirectMiddleware.php
11 months ago
PostObject.php
11 months ago
PostObjectV4.php
11 months ago
PutObjectUrlMiddleware.php
11 months ago
RetryableMalformedResponseParser.php
11 months ago
S3Client.php
11 months ago
S3ClientInterface.php
11 months ago
S3ClientTrait.php
11 months ago
S3EndpointMiddleware.php
11 months ago
S3MultiRegionClient.php
11 months ago
S3UriParser.php
11 months ago
SSECMiddleware.php
11 months ago
StreamWrapper.php
11 months ago
Transfer.php
11 months ago
ValidateResponseChecksumParser.php
11 months ago
RetryableMalformedResponseParser.php
57 lines
| 1 | <?php |
| 2 | namespace Aws\S3; |
| 3 | |
| 4 | use Aws\Api\Parser\AbstractParser; |
| 5 | use Aws\Api\StructureShape; |
| 6 | use Aws\Api\Parser\Exception\ParserException; |
| 7 | use Aws\CommandInterface; |
| 8 | use Aws\Exception\AwsException; |
| 9 | use Psr\Http\Message\ResponseInterface; |
| 10 | use Psr\Http\Message\StreamInterface; |
| 11 | |
| 12 | /** |
| 13 | * Converts malformed responses to a retryable error type. |
| 14 | * |
| 15 | * @internal |
| 16 | */ |
| 17 | class RetryableMalformedResponseParser extends AbstractParser |
| 18 | { |
| 19 | /** @var string */ |
| 20 | private $exceptionClass; |
| 21 | |
| 22 | public function __construct( |
| 23 | callable $parser, |
| 24 | $exceptionClass = AwsException::class |
| 25 | ) { |
| 26 | $this->parser = $parser; |
| 27 | $this->exceptionClass = $exceptionClass; |
| 28 | } |
| 29 | |
| 30 | public function __invoke( |
| 31 | CommandInterface $command, |
| 32 | ResponseInterface $response |
| 33 | ) { |
| 34 | $fn = $this->parser; |
| 35 | |
| 36 | try { |
| 37 | return $fn($command, $response); |
| 38 | } catch (ParserException $e) { |
| 39 | throw new $this->exceptionClass( |
| 40 | "Error parsing response for {$command->getName()}:" |
| 41 | . " AWS parsing error: {$e->getMessage()}", |
| 42 | $command, |
| 43 | ['connection_error' => true, 'exception' => $e], |
| 44 | $e |
| 45 | ); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | public function parseMemberFromStream( |
| 50 | StreamInterface $stream, |
| 51 | StructureShape $member, |
| 52 | $response |
| 53 | ) { |
| 54 | return $this->parser->parseMemberFromStream($stream, $member, $response); |
| 55 | } |
| 56 | } |
| 57 |