當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。