← All changes
|
includes/sdk/s3/Aws/Api/Serializer/RestJsonSerializer.php
+4
-3
1.2.13
→
1.4.2
View file →
| @@ -18,17 +18,18 @@ | ||
| 18 | 18 | * @param Service $api Service API description |
| 19 | 19 | * @param string $endpoint Endpoint to connect to |
| 20 | 20 | * @param JsonBody $jsonFormatter Optional JSON formatter to use |
| 21 | 21 | */ |
| 22 | - public function __construct(Service $api, $endpoint, JsonBody $jsonFormatter = null) | |
| 22 | + public function __construct(Service $api, $endpoint, ?JsonBody $jsonFormatter = null) | |
| 23 | 23 | { |
| 24 | 24 | parent::__construct($api, $endpoint); |
| 25 | 25 | $this->contentType = JsonBody::getContentType($api); |
| 26 | 26 | $this->jsonFormatter = $jsonFormatter ?: new JsonBody($api); |
| 27 | 27 | } |
| 28 | - protected function payload(StructureShape $member, array $value, array &$opts) | |
| 28 | + protected function payload(StructureShape $member, array|string $value, array &$opts) | |
| 29 | 29 | { |
| 30 | - $body = isset($value) ? (string) $this->jsonFormatter->build($member, $value) : "{}"; | |
| 31 | 30 | $opts['headers']['Content-Type'] = $this->contentType; |
| 31 | + $body = $this->jsonFormatter->build($member, $value); | |
| 32 | + $opts['headers']['Content-Length'] = \strlen($body); | |
| 32 | 33 | $opts['body'] = $body; |
| 33 | 34 | } |
| 34 | 35 | } |