当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Http_Response::factory方法代码示例

本文整理汇总了PHP中Zend_Http_Response::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Response::factory方法的具体用法?PHP Zend_Http_Response::factory怎么用?PHP Zend_Http_Response::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Http_Response的用法示例。


在下文中一共展示了Zend_Http_Response::factory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLineBreaksCompatibility

 public function testLineBreaksCompatibility()
 {
     $response_text_lf = file_get_contents(dirname(__FILE__) . '/_files/response_lfonly');
     $res_lf = Zend_Http_Response::factory($response_text_lf);
     $response_text_crlf = file_get_contents(dirname(__FILE__) . '/_files/response_crlf');
     $res_crlf = Zend_Http_Response::factory($response_text_crlf);
     $this->assertEquals($res_lf->getHeadersAsString(true), $res_crlf->getHeadersAsString(true), 'Responses headers do not match');
     $this->assertEquals($res_lf->getBody(), $res_crlf->getBody(), 'Response bodies do not match');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:ResponseTest.php

示例2: request

 /**
  * Send the HTTP request and return a response
  *
  * @param string $method
  * @return Zend_Http_Response
  */
 public function request($method = null)
 {
     if (!$this->uri instanceof Zend_Uri_Http) {
         throw new Zend_Http_Exception("No valid URI has been passed to the client");
     }
     if ($method) {
         $this->setMethod($method);
     }
     // Prepare the request string
     $body = $this->_prepare_body();
     $headers = $this->_prepare_headers();
     $request = $headers . "\r\n" . $body;
     // Open the connection, send the request and read the response
     $sock = $this->_connect();
     $this->_write($sock, $request);
     $response = $this->_read($sock);
     $this->last_request = $request;
     return Zend_Http_Response::factory($response);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:25,代码来源:Abstract.php

示例3: request

 /**
  * Send the HTTP request and return an HTTP response object
  *
  * @param string $method
  * @return Zend_Http_Response
  */
 public function request($method = null)
 {
     if (!$this->uri instanceof Zend_Uri_Http) {
         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;
     // Send the first request. If redirected, continue.
     do {
         // Clone the URI and add the additional GET parameters to it
         $uri = clone $this->uri;
         $uri_params = array();
         parse_str($uri->getQuery(), $uri_params);
         $uri->setQuery(array_merge($uri_params, $this->paramsGet));
         $body = $this->prepare_body();
         $headers = $this->prepare_headers();
         $request = implode("\r\n", $headers) . "\r\n" . $body;
         $this->last_request = $request;
         // Open the connection, send the request and read the response
         $this->adapter->connect($uri->getHost(), $uri->getPort(), $uri->getScheme() == 'https' ? true : false);
         $this->adapter->write($this->method, $uri, $this->config['httpversion'], $headers, $body);
         $response = Zend_Http_Response::factory($this->adapter->read());
         // Load cookies into cookie jar
         if (isset($this->Cookiejar)) {
             $this->Cookiejar->addCookiesFromResponse($response, $uri);
         }
         // If we got redirected, look for the Location header
         if ($response->isRedirect() && ($location = $response->getHeader('location'))) {
             // Check whether we send the exact same request again, or drop the parameters
             // and send a GET request
             if ($response->getStatus() == 303 || !$this->config['strictredirects'] && ($response->getStatus() == 302 || $response->getStatus() == 301)) {
                 $this->resetParameters();
                 $this->setMethod(self::GET);
             }
             // If we got a well formed absolute URI
             if (Zend_Uri_Http::check($location)) {
                 $this->setHeaders('host', null);
                 $this->setUri($location);
             } else {
                 // Split into path and query and set the query
                 list($location, $query) = explode('?', $location, 2);
                 $this->uri->setQueryString($query);
                 // Else, if we got just an absolute path, set it
                 if (strpos($location, '/') === 0) {
                     $this->uri->setPath($location);
                     // Else, assume we have a relative path
                 } else {
                     // Get the current path directory, removing any trailing slashes
                     $path = rtrim(dirname($this->uri->getPath()), "/");
                     $this->uri->setPath($path . '/' . $location);
                 }
             }
             $this->redirectCounter++;
         } else {
             // If we didn't get any location, stop redirecting
             break;
         }
     } while ($this->redirectCounter < $this->config['maxredirects']);
     return $response;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:69,代码来源:Client.php


注:本文中的Zend_Http_Response::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。