PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / S3 / AmbiguousSuccessParser.php
transferito / vendor / aws / aws-sdk-php / src / S3 Last commit date
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
AmbiguousSuccessParser.php
80 lines
1 <?php
2 namespace Aws\S3;
3
4 use Aws\Api\Parser\AbstractParser;
5 use Aws\Api\Parser\Exception\ParserException;
6 use Aws\Api\StructureShape;
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 errors returned with a status code of 200 to a retryable error type.
14 *
15 * @internal
16 */
17 class AmbiguousSuccessParser extends AbstractParser
18 {
19 private static $ambiguousSuccesses = [
20 'UploadPart' => true,
21 'UploadPartCopy' => true,
22 'CopyObject' => true,
23 'CompleteMultipartUpload' => true,
24 ];
25
26 /** @var callable */
27 private $errorParser;
28 /** @var string */
29 private $exceptionClass;
30
31 public function __construct(
32 callable $parser,
33 callable $errorParser,
34 $exceptionClass = AwsException::class
35 ) {
36 $this->parser = $parser;
37 $this->errorParser = $errorParser;
38 $this->exceptionClass = $exceptionClass;
39 }
40
41 public function __invoke(
42 CommandInterface $command,
43 ResponseInterface $response
44 ) {
45 if (200 === $response->getStatusCode()
46 && isset(self::$ambiguousSuccesses[$command->getName()])
47 ) {
48 $errorParser = $this->errorParser;
49 try {
50 $parsed = $errorParser($response);
51 } catch (ParserException $e) {
52 $parsed = [
53 'code' => 'ConnectionError',
54 'message' => "An error connecting to the service occurred"
55 . " while performing the " . $command->getName()
56 . " operation."
57 ];
58 }
59 if (isset($parsed['code']) && isset($parsed['message'])) {
60 throw new $this->exceptionClass(
61 $parsed['message'],
62 $command,
63 ['connection_error' => true]
64 );
65 }
66 }
67
68 $fn = $this->parser;
69 return $fn($command, $response);
70 }
71
72 public function parseMemberFromStream(
73 StreamInterface $stream,
74 StructureShape $member,
75 $response
76 ) {
77 return $this->parser->parseMemberFromStream($stream, $member, $response);
78 }
79 }
80