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


PHP HTTP_Request2::setLastEvent方法代碼示例

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


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

示例1: testDetach

 public function testDetach()
 {
     $request = new HTTP_Request2();
     $observer = new HTTP_Request2_MockObserver();
     $observer2 = new HTTP_Request2_MockObserver();
     $request->attach($observer);
     $request->detach($observer2);
     // should not be a error
     $request->setLastEvent('first');
     $request->detach($observer);
     $request->setLastEvent('second');
     $this->assertEquals(1, $observer->calls);
     $this->assertEquals(array('name' => 'first', 'data' => null), $observer->event);
 }
開發者ID:Geeklog-Core,項目名稱:geeklog,代碼行數:14,代碼來源:ObserverTest.php

示例2: sendRequest

 /**
  * Sends request to the remote server and returns its response
  *
  * @param    HTTP_Request2
  * @return   HTTP_Request2_Response
  * @throws   HTTP_Request2_Exception
  */
 public function sendRequest(HTTP_Request2 $request)
 {
     if (!extension_loaded('curl')) {
         throw new HTTP_Request2_LogicException('cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION);
     }
     $this->request = $request;
     $this->response = null;
     $this->position = 0;
     $this->eventSentHeaders = false;
     $this->eventReceivedHeaders = false;
     try {
         if (false === curl_exec($ch = $this->createCurlHandle())) {
             $e = self::wrapCurlError($ch);
         }
     } catch (Exception $e) {
     }
     if (isset($ch)) {
         $this->lastInfo = curl_getinfo($ch);
         curl_close($ch);
     }
     $response = $this->response;
     unset($this->request, $this->requestBody, $this->response);
     if (!empty($e)) {
         throw $e;
     }
     if ($jar = $request->getCookieJar()) {
         $jar->addCookiesFromResponse($response, $request->getUrl());
     }
     if (0 < $this->lastInfo['size_download']) {
         $request->setLastEvent('receivedBody', $response);
     }
     return $response;
 }
開發者ID:venamax,項目名稱:trixandtrax-cl,代碼行數:40,代碼來源:Curl.php

示例3: sendRequest

 /**
  * Sends request to the remote server and returns its response
  *
  * @param    HTTP_Request2
  * @return   HTTP_Request2_Response
  * @throws   HTTP_Request2_Exception
  */
 public function sendRequest(HTTP_Request2 $request)
 {
     if (!extension_loaded('curl')) {
         throw new HTTP_Request2_Exception('cURL extension not available');
     }
     $this->request = $request;
     $this->response = null;
     $this->position = 0;
     $this->eventSentHeaders = false;
     $this->eventReceivedHeaders = false;
     try {
         if (false === curl_exec($ch = $this->createCurlHandle())) {
             $errorMessage = 'Error sending request: #' . curl_errno($ch) . ' ' . curl_error($ch);
         }
     } catch (Exception $e) {
     }
     $this->lastInfo = curl_getinfo($ch);
     curl_close($ch);
     $response = $this->response;
     unset($this->request, $this->requestBody, $this->response);
     if (!empty($e)) {
         throw $e;
     } elseif (!empty($errorMessage)) {
         throw new HTTP_Request2_Exception($errorMessage);
     }
     if (0 < $this->lastInfo['size_download']) {
         $request->setLastEvent('receivedBody', $response);
     }
     return $response;
 }
開發者ID:rubythonode,項目名稱:xe-core,代碼行數:37,代碼來源:Curl.php


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