protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response)
    {
        // Do not close socket on successful CONNECT request
        if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod()
            && 200 <= $response->getStatus() && 300 > $response->getStatus()
        ) {
            return true;
        }

        $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding'))
                       || null !== $response->getHeader('content-length')
                       // no body possible for such responses, see also request #17031
                       || HTTP_Request2::METHOD_HEAD == $this->request->getMethod()
                       || in_array($response->getStatus(), array(204, 304));
        $persistent  = 'keep-alive' == strtolower($response->getHeader('connection')) ||
                       (null === $response->getHeader('connection') &&
                        '1.1' == $response->getVersion());
        return $requestKeepAlive && $lengthKnown && $persistent;
    }
protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response)
    {
        // Do not close socket on successful CONNECT request
        if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod()
            && 200 <= $response->getStatus() && 300 > $response->getStatus()
        ) {
            return true;
        }

        $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding'))
                       || null !== $response->getHeader('content-length')
                       // no body possible for such responses, see also request #17031
                       || HTTP_Request2::METHOD_HEAD == $this->request->getMethod()
                       || in_array($response->getStatus(), array(204, 304));
        $persistent  = 'keep-alive' == strtolower($response->getHeader('connection')) ||
                       (null === $response->getHeader('connection') &&
                        '1.1' == $response->getVersion());
        return $requestKeepAlive && $lengthKnown && $persistent;
    }
protected function canKeepAlive ( $ requestKeepAlive , HTTP_Request2_Response $ response ) { // Do not close socket on successful CONNECT request
 if ( HTTP_Request2 :: METHOD_CONNECT == $ this -> request -> getMethod ( ) && 200 <= $ response -> getStatus ( ) && 300 > $ response -> getStatus ( ) ) { return true ; } $ lengthKnown = 'chunked' == strtolower ( $ response -> getHeader ( 'transfer-encoding' ) ) || null !== $ response -> getHeader ( 'content-length' ) // no body possible for such responses, see also request #17031
 || HTTP_Request2 :: METHOD_HEAD == $ this -> request -> getMethod ( ) || in_array ( $ response -> getStatus ( ) , array ( 204 , 304 ) ) ; $ persistent = 'keep-alive' == strtolower ( $ response -> getHeader ( 'connection' ) ) || ( null === $ response -> getHeader ( 'connection' ) && '1.1' == $ response -> getVersion ( ) ) ; return $ requestKeepAlive && $ lengthKnown && $ persistent ; }
Checks whether current connection may be reused or should be closed

@param boolean                $requestKeepAlive whether connection could
be persistent in the first place
@param HTTP_Request2_Response $response         response object to check

@return   boolean
Checks whether current connection may be reused or should be closed