src/Guzzle/Http/Message/Response.php
public static function fromMessage($message)
    {
        $data = ParserRegistry::getInstance()->getParser('message')->parseResponse($message);
        if (!$data) {
            return false;
        }

        $response = new static($data['code'], $data['headers'], $data['body']);
        $response->setProtocol($data['protocol'], $data['version'])
                 ->setStatus($data['code'], $data['reason_phrase']);

        // Set the appropriate Content-Length if the one set is inaccurate (e.g. setting to X)
        $contentLength = (string) $response->getHeader('Content-Length');
        $actualLength = strlen($data['body']);
        if (strlen($data['body']) > 0 && $contentLength != $actualLength) {
            $response->setHeader('Content-Length', $actualLength);
        }

        return $response;
    }
public static function fromMessage($message)
    {
        $data = ParserRegistry::getInstance()->getParser('message')->parseResponse($message);
        if (!$data) {
            return false;
        }

        $response = new static($data['code'], $data['headers'], $data['body']);
        $response->setProtocol($data['protocol'], $data['version'])
                 ->setStatus($data['code'], $data['reason_phrase']);

        // Set the appropriate Content-Length if the one set is inaccurate (e.g. setting to X)
        $contentLength = (string) $response->getHeader('Content-Length');
        $actualLength = strlen($data['body']);
        if (strlen($data['body']) > 0 && $contentLength != $actualLength) {
            $response->setHeader('Content-Length', $actualLength);
        }

        return $response;
    }
public static function fromMessage ( $ message ) { $ data = ParserRegistry :: getInstance ( ) -> getParser ( 'message' ) -> parseResponse ( $ message ) ; if ( ! $ data ) { return false ; } $ response = new static ( $ data [ 'code' ] , $ data [ 'headers' ] , $ data [ 'body' ] ) ; $ response -> setProtocol ( $ data [ 'protocol' ] , $ data [ 'version' ] ) -> setStatus ( $ data [ 'code' ] , $ data [ 'reason_phrase' ] ) ; // Set the appropriate Content-Length if the one set is inaccurate (e.g. setting to X) $ contentLength = ( string ) $ response -> getHeader ( 'Content-Length' ) ; $ actualLength = strlen ( $ data [ 'body' ] ) ; if ( strlen ( $ data [ 'body' ] ) > 0 && $ contentLength != $ actualLength ) { $ response -> setHeader ( 'Content-Length' , $ actualLength ) ; } return $ response ; }
Create a new Response based on a raw response message

@param string $message Response message

@return self|bool Returns false on error
Create a new Response based on a raw response message