當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HTTPRequest::getResponseHeader方法代碼示例

本文整理匯總了PHP中HTTPRequest::getResponseHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTTPRequest::getResponseHeader方法的具體用法?PHP HTTPRequest::getResponseHeader怎麽用?PHP HTTPRequest::getResponseHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HTTPRequest的用法示例。


在下文中一共展示了HTTPRequest::getResponseHeader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _send_message

 /**
  * Sends the HTTP message [Request] to a remote server and processes
  * the response.
  *
  * @param   Request   $request  request to send
  * @param   Response  $request  response to send
  * @return  Response
  */
 public function _send_message(Request $request, Response $response)
 {
     $http_method_mapping = array(HTTP_Request::GET => HTTPRequest::METH_GET, HTTP_Request::HEAD => HTTPRequest::METH_HEAD, HTTP_Request::POST => HTTPRequest::METH_POST, HTTP_Request::PUT => HTTPRequest::METH_PUT, HTTP_Request::DELETE => HTTPRequest::METH_DELETE, HTTP_Request::OPTIONS => HTTPRequest::METH_OPTIONS, HTTP_Request::TRACE => HTTPRequest::METH_TRACE, HTTP_Request::CONNECT => HTTPRequest::METH_CONNECT);
     // Create an http request object
     $http_request = new HTTPRequest($request->uri(), $http_method_mapping[$request->method()]);
     if ($this->_options) {
         // Set custom options
         $http_request->setOptions($this->_options);
     }
     // Set headers
     $http_request->setHeaders($request->headers()->getArrayCopy());
     // Set cookies
     $http_request->setCookies($request->cookie());
     // Set query data (?foo=bar&bar=foo)
     $http_request->setQueryData($request->query());
     // Set the body
     if ($request->method() == HTTP_Request::PUT) {
         $http_request->addPutData($request->body());
     } else {
         $http_request->setBody($request->body());
     }
     try {
         $http_request->send();
     } catch (HTTPRequestException $e) {
         throw new Request_Exception($e->getMessage());
     } catch (HTTPMalformedHeaderException $e) {
         throw new Request_Exception($e->getMessage());
     } catch (HTTPEncodingException $e) {
         throw new Request_Exception($e->getMessage());
     }
     // Build the response
     $response->status($http_request->getResponseCode())->headers($http_request->getResponseHeader())->cookie($http_request->getResponseCookies())->body($http_request->getResponseBody());
     return $response;
 }
開發者ID:artbypravesh,項目名稱:morningpages,代碼行數:42,代碼來源:HTTP.php

示例2: call

 function call()
 {
     if (func_num_args() < 1) {
         return false;
     }
     $request = new HTTPRequest();
     $request->method = 'POST';
     $request->url = $this->url;
     $request->contentType = 'text/xml';
     $request->async = $this->async;
     ob_start();
     echo '<?xml version="1.0" encoding="utf-8"?><methodCall><methodName>' . func_get_arg(0) . '</methodName><params>';
     for ($i = 1; $i < func_num_args(); $i++) {
         echo '<param>';
         echo $this->_encodeValue(func_get_arg($i));
         echo '</param>';
     }
     echo '</params></methodCall>';
     $request->content = ob_get_contents();
     ob_end_clean();
     if (!$request->send()) {
         return false;
     }
     if ($this->async) {
         return true;
     }
     if (!is_null($request->getResponseHeader('Content-Type')) && $request->getResponseHeader('Content-Type') != 'text/xml') {
         return false;
     }
     $xmls = new XMLStruct();
     $request->responseText = preg_replace_callback('/&#([0-9a-fx]+);/mi', 'replace_num_entity', $request->responseText);
     $xmls->open($request->responseText);
     if ($xmls->error) {
         return false;
     }
     if (isset($xmls->struct['methodResponse'][0]['fault'][0]['value'])) {
         $this->fault = $this->_decodeValue($xmls->struct['methodResponse'][0]['fault'][0]['value'][0]);
     } else {
         if (isset($xmls->struct['methodResponse'][0]['params'][0]['param'][0]['value'])) {
             $this->result = $this->_decodeValue($xmls->struct['methodResponse'][0]['params'][0]['param'][0]['value'][0]);
         } else {
             return false;
         }
     }
     return true;
 }
開發者ID:ni5am,項目名稱:Textcube,代碼行數:46,代碼來源:Needlworks.PHP.XMLRPC.php

示例3: _http_execute

 /**
  * Execute the request using the PECL HTTP extension. (recommended)
  *
  * @param   Request   $request Request to execute
  * @return  Response
  */
 protected function _http_execute(Request $request)
 {
     $http_method_mapping = array(HTTP_Request::GET => HTTPRequest::METH_GET, HTTP_Request::HEAD => HTTPRequest::METH_HEAD, HTTP_Request::POST => HTTPRequest::METH_POST, HTTP_Request::PUT => HTTPRequest::METH_PUT, HTTP_Request::DELETE => HTTPRequest::METH_DELETE, HTTP_Request::OPTIONS => HTTPRequest::METH_OPTIONS, HTTP_Request::TRACE => HTTPRequest::METH_TRACE, HTTP_Request::CONNECT => HTTPRequest::METH_CONNECT);
     // Create an http request object
     $http_request = new HTTPRequest($request->uri(), $http_method_mapping[$request->method()]);
     // Set custom options
     $http_request->setOptions($this->_options);
     // Set headers
     $http_request->setHeaders($request->headers()->getArrayCopy());
     // Set cookies
     $http_request->setCookies($request->cookie());
     // Set body
     $http_request->setBody($request->body());
     try {
         $http_request->send();
     } catch (HTTPRequestException $e) {
         throw new Kohana_Request_Exception($e->getMessage());
     } catch (HTTPMalformedHeaderException $e) {
         throw new Kohana_Request_Exception($e->getMessage());
     } catch (HTTPEncodingException $e) {
         throw new Kohana_Request_Exception($e->getMessage());
     }
     // Create the response
     $response = $request->create_response();
     // Build the response
     $response->status($http_request->getResponseCode())->headers($http_request->getResponseHeader())->cookie($http_request->getResponseCookies())->body($http_request->getResponseBody());
     return $response;
 }
開發者ID:ricasiano,項目名稱:sapakan,代碼行數:34,代碼來源:external.php


注:本文中的HTTPRequest::getResponseHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。