本文整理汇总了PHP中Zend_Http_Client_Adapter_Interface::setOutputStream方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client_Adapter_Interface::setOutputStream方法的具体用法?PHP Zend_Http_Client_Adapter_Interface::setOutputStream怎么用?PHP Zend_Http_Client_Adapter_Interface::setOutputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Http_Client_Adapter_Interface
的用法示例。
在下文中一共展示了Zend_Http_Client_Adapter_Interface::setOutputStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: request
/**
* Send the HTTP request and return an HTTP response object
*
* @param string $method
* @return Zend_Http_Response
* @throws Zend_Http_Client_Exception
*/
public function request($method = null)
{
if (!$this->uri instanceof Zend_Uri_Http) {
/** @see Zend_Http_Client_Exception */
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception('No valid URI has been passed to the client');
}
if ($method) {
$this->setMethod($method);
}
$this->redirectCounter = 0;
$response = null;
// Make sure the adapter is loaded
if ($this->adapter == null) {
$this->setAdapter($this->config['adapter']);
}
// Send the first request. If redirected, continue.
do {
// Clone the URI and add the additional GET parameters to it
$uri = clone $this->uri;
if (!empty($this->paramsGet)) {
$query = $uri->getQuery();
if (!empty($query)) {
$query .= '&';
}
$query .= http_build_query($this->paramsGet, null, '&');
if ($this->config['rfc3986_strict']) {
$query = str_replace('+', '%20', $query);
}
// @see ZF-11671 to unmask for some services to foo=val1&foo=val2
if ($this->getUnmaskStatus()) {
if ($this->_queryBracketsEscaped) {
$query = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $query);
} else {
$query = preg_replace('/\\[(?:[0-9]|[1-9][0-9]+)\\]=/', '=', $query);
}
}
$uri->setQuery($query);
}
$body = $this->_prepareBody();
$headers = $this->_prepareHeaders();
// check that adapter supports streaming before using it
if (is_resource($body) && !$this->adapter instanceof Zend_Http_Client_Adapter_Stream) {
/** @see Zend_Http_Client_Exception */
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception('Adapter does not support streaming');
}
// Open the connection, send the request and read the response
$this->adapter->connect($uri->getHost(), $uri->getPort(), $uri->getScheme() == 'https' ? true : false);
if ($this->config['output_stream']) {
if ($this->adapter instanceof Zend_Http_Client_Adapter_Stream) {
$stream = $this->_openTempStream();
$this->adapter->setOutputStream($stream);
} else {
/** @see Zend_Http_Client_Exception */
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception('Adapter does not support streaming');
}
}
$this->last_request = $this->adapter->write($this->method, $uri, $this->config['httpversion'], $headers, $body);
$response = $this->adapter->read();
if (!$response) {
/** @see Zend_Http_Client_Exception */
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception('Unable to read response, or response is empty');
}
if ($this->config['output_stream']) {
$streamMetaData = stream_get_meta_data($stream);
if ($streamMetaData['seekable']) {
rewind($stream);
}
// cleanup the adapter
$this->adapter->setOutputStream(null);
$response = Zend_Http_Response_Stream::fromStream($response, $stream);
$response->setStreamName($this->_stream_name);
if (!is_string($this->config['output_stream'])) {
// we used temp name, will need to clean up
$response->setCleanup(true);
}
} else {
$response = Zend_Http_Response::fromString($response);
}
if ($this->config['storeresponse']) {
$this->last_response = $response;
}
// Load cookies into cookie jar
if (isset($this->cookiejar)) {
$this->cookiejar->addCookiesFromResponse($response, $uri, $this->config['encodecookies']);
}
// If we got redirected, look for the Location header
if ($response->isRedirect() && ($location = $response->getHeader('location'))) {
// Avoid problems with buggy servers that add whitespace at the
// end of some headers (See ZF-11283)
//.........这里部分代码省略.........