src/Qcloud/Cos/ExceptionParser.php
protected function parseHeaders(RequestInterface $request, Response $response, array &$data) {
        $data['message'] = $response->getStatusCode() . ' ' . $response->getReasonPhrase();
        if ($requestId = $response->getHeader('x-cos-request-id')) {
            $data['request_id'] = $requestId;
            $data['message'] .= " (Request-ID: $requestId)";
        }

        // 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';
            }
        }
    }
protected function parseHeaders(RequestInterface $request, Response $response, array &$data) {
        $data['message'] = $response->getStatusCode() . ' ' . $response->getReasonPhrase();
        if ($requestId = $response->getHeader('x-cos-request-id')) {
            $data['request_id'] = $requestId;
            $data['message'] .= " (Request-ID: $requestId)";
        }

        // 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';
            }
        }
    }
protected function parseHeaders ( RequestInterface $ request , Response $ response , array & $ data ) { $ data [ 'message' ] = $ response -> getStatusCode ( ) . ' ' . $ response -> getReasonPhrase ( ) ; if ( $ requestId = $ response -> getHeader ( 'x-cos-request-id' ) ) { $ data [ 'request_id' ] = $ requestId ; $ data [ 'message' ] .= " (Request-ID: $requestId)" ; } // 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' ; } } }
Parses additional exception information from the response headers

@param RequestInterface $request  Request that was issued
@param Response         $response The response from the request
@param array            $data     The current set of exception data
Parses additional exception information from the response headers