extractCode example

while (($line = @fgets($this->socket)) !== false) {
            $gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
            if ($gotStatus) {
                $response .= $line;
                if (rtrim($line) === '') break;
            }
        }

        $this->_checkSocketReadTimeout();

        $statusCode = Zend_Http_Response::extractCode($response);

        // Handle 100 and 101 responses internally by restarting the read again         if ($statusCode == 100 || $statusCode == 101) return $this->read();

        // Check headers to see what kind of connection / transfer encoding we have         $headers = Zend_Http_Response::extractHeaders($response);

        /** * Responses to HEAD requests and 204 or 304 responses are not expected * to have a body - stop reading here */
        

    }

    /** * Create a new Zend_Http_Response object from a string * * @param string $response_str * @return Zend_Http_Response */
    public static function fromString($response_str)
    {
        $code    = self::extractCode($response_str);
        $headers = self::extractHeaders($response_str);
        $body    = self::extractBody($response_str);
        $version = self::extractVersion($response_str);
        $message = self::extractMessage($response_str);

        return new Zend_Http_Response($code$headers$body$version$message);
    }
}


    /** * Create a new Zend_Http_Response_Stream object from a string * * @param string $response_str * @param resource $stream * @return Zend_Http_Response_Stream */
    public static function fromStream($response_str$stream)
    {
        $code    = self::extractCode($response_str);
        $headers = self::extractHeaders($response_str);
        $version = self::extractVersion($response_str);
        $message = self::extractMessage($response_str);

        return new self($code$headers$stream$version$message);
    }

    /** * Get the response body as string * * This method returns the body of the HTTP response (the content), as it * should be in it's readable version - that is, after decoding it (if it * was decoded), deflating it (if it was gzip compressed), etc. * * If you want to get the raw body (as transfered on wire) use * $this->getRawBody() instead. * * @return string */
while ($line = @fgets($this->socket)) {
            $gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
            if ($gotStatus) {
                $response .= $line;
                if (!chop($line)) {
                    break;
                }
            }
        }

        // Check that the response from the proxy is 200         if (Zend_Http_Response::extractCode($response) != 200) {
            throw new Zend_Http_Client_Adapter_Exception(
                'Unable to connect to HTTPS proxy. Server response: ' . $response
            );
        }

        // If all is good, switch socket to secure mode. We have to fall back         // through the different modes         $modes = array(
            STREAM_CRYPTO_METHOD_TLS_CLIENT,
            STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
            STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
            
Home | Imprint | This part of the site doesn't use cookies.