composer update
This commit is contained in:
@@ -20,7 +20,7 @@ trait JsonParserTrait
|
||||
'code' => null,
|
||||
'message' => null,
|
||||
'type' => $code[0] == '4' ? 'client' : 'server',
|
||||
'parsed' => $this->parseJson($response->getBody())
|
||||
'parsed' => $this->parseJson($response->getBody(), $response)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class XmlErrorParser
|
||||
|
||||
$body = $response->getBody();
|
||||
if ($body->getSize() > 0) {
|
||||
$this->parseBody($this->parseXml($body), $data);
|
||||
$this->parseBody($this->parseXml($body, $response), $data);
|
||||
} else {
|
||||
$this->parseHeaders($response, $data);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ abstract class AbstractParser
|
||||
|
||||
abstract public function parseMemberFromStream(
|
||||
StreamInterface $stream,
|
||||
StructureShape $member
|
||||
StructureShape $member,
|
||||
$response
|
||||
);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ abstract class AbstractRestParser extends AbstractParser
|
||||
}
|
||||
case 'string':
|
||||
if ($shape['jsonvalue']) {
|
||||
$value = $this->parseJson(base64_decode($value));
|
||||
$value = $this->parseJson(base64_decode($value), $response);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,9 @@ class Crc32ValidatingParser extends AbstractParser
|
||||
|
||||
public function parseMemberFromStream(
|
||||
StreamInterface $stream,
|
||||
StructureShape $member
|
||||
StructureShape $member,
|
||||
$response
|
||||
) {
|
||||
return $this->parser->parseMemberFromStream($stream, $member);
|
||||
return $this->parser->parseMemberFromStream($stream, $member, $response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ class EventParsingIterator implements Iterator
|
||||
} else {
|
||||
$parsedEvent[$shape] = $this->parser->parseMemberFromStream(
|
||||
$event['payload'],
|
||||
$payloadShape
|
||||
$payloadShape,
|
||||
null
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
<?php
|
||||
namespace Aws\Api\Parser\Exception;
|
||||
|
||||
class ParserException extends \RuntimeException {}
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
use Aws\ResponseContainerInterface;
|
||||
|
||||
class ParserException extends \RuntimeException implements
|
||||
MonitoringEventsInterface,
|
||||
ResponseContainerInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
|
||||
private $response;
|
||||
|
||||
public function __construct($message = '', $code = 0, $previous = null, array $context = [])
|
||||
{
|
||||
$this->response = isset($context['response']) ? $context['response'] : null;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the received HTTP response if any.
|
||||
*
|
||||
* @return ResponseInterface|null
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ class JsonRpcParser extends AbstractParser
|
||||
? null
|
||||
: $this->parseMemberFromStream(
|
||||
$response->getBody(),
|
||||
$operation->getOutput()
|
||||
$operation->getOutput(),
|
||||
$response
|
||||
);
|
||||
|
||||
return new Result($result ?: []);
|
||||
@@ -42,8 +43,9 @@ class JsonRpcParser extends AbstractParser
|
||||
|
||||
public function parseMemberFromStream(
|
||||
StreamInterface $stream,
|
||||
StructureShape $member
|
||||
StructureShape $member,
|
||||
$response
|
||||
) {
|
||||
return $this->parser->parse($member, $this->parseJson($stream));
|
||||
return $this->parser->parse($member, $this->parseJson($stream, $response));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace Aws\Api\Parser;
|
||||
|
||||
use Aws\Api\Parser\Exception\ParserException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
trait PayloadParserTrait
|
||||
{
|
||||
@@ -12,13 +13,17 @@ trait PayloadParserTrait
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function parseJson($json)
|
||||
private function parseJson($json, $response)
|
||||
{
|
||||
$jsonPayload = json_decode($json, true);
|
||||
|
||||
if (JSON_ERROR_NONE !== json_last_error()) {
|
||||
throw new ParserException('Error parsing JSON: '
|
||||
. json_last_error_msg());
|
||||
throw new ParserException(
|
||||
'Error parsing JSON: ' . json_last_error_msg(),
|
||||
0,
|
||||
null,
|
||||
['response' => $response]
|
||||
);
|
||||
}
|
||||
|
||||
return $jsonPayload;
|
||||
@@ -31,7 +36,7 @@ trait PayloadParserTrait
|
||||
*
|
||||
* @return \SimpleXMLElement
|
||||
*/
|
||||
private function parseXml($xml)
|
||||
private function parseXml($xml, $response)
|
||||
{
|
||||
$priorSetting = libxml_use_internal_errors(true);
|
||||
try {
|
||||
@@ -41,7 +46,12 @@ trait PayloadParserTrait
|
||||
throw new \RuntimeException($error->message);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new ParserException("Error parsing XML: {$e->getMessage()}", 0, $e);
|
||||
throw new ParserException(
|
||||
"Error parsing XML: {$e->getMessage()}",
|
||||
0,
|
||||
$e,
|
||||
['response' => $response]
|
||||
);
|
||||
} finally {
|
||||
libxml_use_internal_errors($priorSetting);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class QueryParser extends AbstractParser
|
||||
ResponseInterface $response
|
||||
) {
|
||||
$output = $this->api->getOperation($command->getName())->getOutput();
|
||||
$xml = $this->parseXml($response->getBody());
|
||||
$xml = $this->parseXml($response->getBody(), $response);
|
||||
|
||||
if ($this->honorResultWrapper && $output['resultWrapper']) {
|
||||
$xml = $xml->{$output['resultWrapper']};
|
||||
@@ -51,9 +51,10 @@ class QueryParser extends AbstractParser
|
||||
|
||||
public function parseMemberFromStream(
|
||||
StreamInterface $stream,
|
||||
StructureShape $member
|
||||
StructureShape $member,
|
||||
$response
|
||||
) {
|
||||
$xml = $this->parseXml($stream);
|
||||
$xml = $this->parseXml($stream, $response);
|
||||
return $this->parser->parse($member, $xml);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class RestJsonParser extends AbstractRestParser
|
||||
StructureShape $member,
|
||||
array &$result
|
||||
) {
|
||||
$jsonBody = $this->parseJson($response->getBody());
|
||||
$jsonBody = $this->parseJson($response->getBody(), $response);
|
||||
|
||||
if ($jsonBody) {
|
||||
$result += $this->parser->parse($member, $jsonBody);
|
||||
@@ -37,9 +37,10 @@ class RestJsonParser extends AbstractRestParser
|
||||
|
||||
public function parseMemberFromStream(
|
||||
StreamInterface $stream,
|
||||
StructureShape $member
|
||||
StructureShape $member,
|
||||
$response
|
||||
) {
|
||||
$jsonBody = $this->parseJson($stream);
|
||||
$jsonBody = $this->parseJson($stream, $response);
|
||||
if ($jsonBody) {
|
||||
return $this->parser->parse($member, $jsonBody);
|
||||
}
|
||||
|
||||
@@ -28,14 +28,15 @@ class RestXmlParser extends AbstractRestParser
|
||||
StructureShape $member,
|
||||
array &$result
|
||||
) {
|
||||
$result += $this->parseMemberFromStream($response->getBody(), $member);
|
||||
$result += $this->parseMemberFromStream($response->getBody(), $member, $response);
|
||||
}
|
||||
|
||||
public function parseMemberFromStream(
|
||||
StreamInterface $stream,
|
||||
StructureShape $member
|
||||
StructureShape $member,
|
||||
$response
|
||||
) {
|
||||
$xml = $this->parseXml($stream);
|
||||
$xml = $this->parseXml($stream, $response);
|
||||
return $this->parser->parse($member, $xml);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,9 @@ class JsonBody
|
||||
= $this->format($valueShape, $v);
|
||||
}
|
||||
}
|
||||
if (empty($data)) {
|
||||
return new \stdClass;
|
||||
}
|
||||
return $data;
|
||||
|
||||
case 'list':
|
||||
|
||||
Reference in New Issue
Block a user