File tree Expand file tree Collapse file tree 2 files changed +4
-27
lines changed
Expand file tree Collapse file tree 2 files changed +4
-27
lines changed Original file line number Diff line number Diff line change @@ -43,33 +43,11 @@ public function __construct(ResponseInterface $response)
4343 $ this ->response = $ response ;
4444 $ code = $ response ->getInfo ('http_code ' );
4545 $ url = $ response ->getInfo ('url ' );
46+ $ content = $ response ->getContent (false );
4647 $ message = sprintf ('HTTP %d returned for "%s". ' , $ code , $ url );
4748
48- $ httpCodeFound = false ;
49- $ isJson = false ;
50- foreach (array_reverse ($ response ->getInfo ('response_headers ' )) as $ h ) {
51- if (0 === strpos ($ h , 'HTTP/ ' )) {
52- if ($ httpCodeFound ) {
53- break ;
54- }
55-
56- $ message = sprintf ('%s returned for "%s". ' , $ h , $ url );
57- $ httpCodeFound = true ;
58- }
59-
60- if (0 === stripos ($ h , 'content-type: ' )) {
61- if (preg_match ('/\bjson\b/i ' , $ h )) {
62- $ isJson = true ;
63- }
64-
65- if ($ httpCodeFound ) {
66- break ;
67- }
68- }
69- }
70-
71- $ content = $ response ->getContent (false );
72- if ($ isJson && $ body = json_decode ($ content , true )) {
49+ // Try json_decode it first, fallback to XML
50+ if ($ body = json_decode ($ content , true )) {
7351 $ this ->parseJson ($ body );
7452 } else {
7553 try {
Original file line number Diff line number Diff line change 88use AsyncAws \Core \Exception \Http \NetworkException ;
99
1010/**
11- * The result promise is always returned from every API call. Remember to call `resolve()` to
12- * make sure the request is actually sent.
11+ * Base class for all return values from a Api Client methods. Example: `FooClient::bar(): Result`.
1312 */
1413class Result
1514{
You can’t perform that action at this time.
0 commit comments