public function testParsesResponsesWithNoBody() { $response = Response::fromMessage("HTTP/1.1 400 Bad Request\r\nX-Amz-Request-ID: Foo\r\n\r\n"); $parser = new DefaultXmlExceptionParser(); $result = $parser->parse($response); $this->assertEquals('400 Bad Request (Request-ID: Foo)', $result['message']); $this->assertEquals('Foo', $result['request_id']); }
/** * {@inheritdoc} */ protected function parseHeaders(RequestInterface $request, Response $response, array &$data) { parent::parseHeaders($request, $response, $data); // Get the request $status = $response->getStatusCode(); $method = $request->getMethod(); // Attempt to determine code for 403s and 404s if ($status === 403) { $data['code'] = 'AccessDenied'; } elseif ($method === 'HEAD' && $status === 404) { $path = explode('/', trim($request->getPath(), '/')); $host = explode('.', $request->getHost()); $bucket = count($host) === 4 ? $host[0] : array_shift($path); $object = array_shift($path); if ($bucket && $object) { $data['code'] = 'NoSuchKey'; } elseif ($bucket) { $data['code'] = 'NoSuchBucket'; } } }