Source for file Stream.php
Documentation is available at Stream.php
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
* @package Microsoft_Http
* @version $Id: Response.php 17131 2009-07-26 10:03:39Z shahar $
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see Microsoft_AutoLoader
require_once dirname(__FILE__ ) . '/../../AutoLoader.php';
* Microsoft_Http_Response represents an HTTP 1.0 / 1.1 response message. It
* includes easy access to all the response's different elemts, as well as some
* convenience methods for parsing and validating HTTP responses.
* @package Microsoft_Http
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* The name of the file containing the stream
* Will be empty if stream is not file-based.
* Should we clean up the stream file when this response is closed?
* Get the response as stream
* Set the response stream
* @param resourse $stream
* @return Microsoft_Http_Response_Stream
* Get the cleanup trigger
* Set the cleanup trigger
* @param $cleanup Set cleanup trigger
* Get file name associated with the stream
* Set file name associated with the stream
* @param string $stream_name Name to set
* @return Microsoft_Http_Response_Stream
* HTTP response constructor
* In most cases, you would use Microsoft_Http_Response::fromString to parse an HTTP
* response string and create a new Microsoft_Http_Response object.
* NOTE: The constructor no longer accepts nulls or empty values for the code and
* headers and will throw an exception if the passed values do not form a valid HTTP
* If no message is passed, the message will be guessed according to the response code.
* @param int $code Response code (200, 404, ...)
* @param array $headers Headers array
* @param string $body Response body
* @param string $version HTTP version
* @param string $message Response code as text
* @throws Microsoft_Http_Exception
public function __construct($code, $headers, $body = null, $version = '1.1', $message = null)
parent::__construct($code, $headers, $body, $version, $message);
* Create a new Microsoft_Http_Response_Stream object from a string
* @param string $response_str
* @param resource $stream
* @return Microsoft_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.
* Get the raw response body (as transfered "on wire") as string
* If the body is encoded (with Transfer-Encoding, not content-encoding -
* IE "chunked" body), gzip compressed, etc. it will not be decoded.
* Read stream content and return it as string
* Function reads the remainder of the body from the stream and closes the stream.
if(isset ($headers['content-length'])) {
|