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


PHP RequestInterface::dispatch方法代碼示例

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


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

示例1: readRequestBody

 /**
  * Read data from the request body and send it to curl
  *
  * @param resource $ch     Curl handle
  * @param resource $fd     File descriptor
  * @param int      $length Amount of data to read
  *
  * @return string
  */
 public function readRequestBody($ch, $fd, $length)
 {
     $read = '';
     if ($this->request->getBody()) {
         $read = $this->request->getBody()->read($length);
         if ($this->emitIo) {
             $this->request->dispatch('curl.callback.read', array('request' => $this->request, 'read' => $read));
         }
     }
     return !$read ? '' : $read;
 }
開發者ID:creazy412,項目名稱:vmware-win10-c65-drupal7,代碼行數:20,代碼來源:RequestMediator.php

示例2: readRequestBody

 /**
  * Read data from the request body and send it to curl
  *
  * @param resource $ch     Curl handle
  * @param resource $fd     File descriptor
  * @param int      $length Amount of data to read
  *
  * @return string
  */
 public function readRequestBody($ch, $fd, $length)
 {
     if (!($body = $this->request->getBody())) {
         return '';
     }
     $read = (string) $body->read($length);
     if ($this->emitIo) {
         $this->request->dispatch('curl.callback.read', array('request' => $this->request, 'read' => $read));
     }
     return $read;
 }
開發者ID:adrianoaguiar,項目名稱:magento-elasticsearch-module,代碼行數:20,代碼來源:RequestMediator.php

示例3: fromRequest

 public function fromRequest(RequestInterface $request, $context = array(), array $params = array())
 {
     if (is_resource($context)) {
         $this->contextOptions = stream_context_get_options($context);
         $this->context = $context;
     } elseif (is_array($context) || !$context) {
         $this->contextOptions = $context;
         $this->createContext($params);
     } elseif ($context) {
         throw new InvalidArgumentException('$context must be an array or resource');
     }
     $request->dispatch('request.before_send', array('request' => $request, 'context' => $this->context, 'context_options' => $this->contextOptions));
     $this->setUrl($request);
     $this->addDefaultContextOptions($request);
     $this->addSslOptions($request);
     $this->addBodyOptions($request);
     $this->addProxyOptions($request);
     return $this->createStream($params)->setCustomData('request', $request)->setCustomData('response_headers', $this->getLastResponseHeaders());
 }
開發者ID:Ryu0621,項目名稱:SaNaVi,代碼行數:19,代碼來源:PhpStreamRequestFactory.php

示例4: beforeSend

 /**
  * Prepare for sending
  *
  * @param RequestInterface $request Request to prepare
  * @throws \Exception on error preparing the request
  */
 protected function beforeSend(RequestInterface $request)
 {
     try {
         // Fix Content-Length and Transfer-Encoding collisions
         if ($request->hasHeader('Transfer-Encoding') && $request->hasHeader('Content-Length')) {
             $request->removeHeader('Transfer-Encoding');
         }
         $request->setState(RequestInterface::STATE_TRANSFER);
         $request->dispatch('request.before_send', array('request' => $request));
         if ($request->getState() != RequestInterface::STATE_TRANSFER) {
             // Requests might decide they don't need to be sent just before transfer (e.g. CachePlugin)
             $this->remove($request);
             if ($request->getState() == RequestInterface::STATE_COMPLETE) {
                 $this->successful[] = $request;
             }
         } else {
             // Add the request curl handle to the multi handle
             $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $this->createCurlHandle($request)->getHandle()));
         }
     } catch (\Exception $e) {
         // Queue the exception to be thrown when sent
         $this->removeErroredRequest($request, $e);
     }
 }
開發者ID:creazy412,項目名稱:vmware-win10-c65-drupal7,代碼行數:30,代碼來源:CurlMulti.php

示例5: beforeSend

 /**
  * Prepare for sending
  *
  * @param RequestInterface $request Request to prepare
  */
 protected function beforeSend(RequestInterface $request)
 {
     try {
         $request->setState(RequestInterface::STATE_TRANSFER);
         $request->dispatch('request.before_send', array('request' => $request));
         if ($request->getState() != RequestInterface::STATE_TRANSFER) {
             // Requests might decide they don't need to be sent just before
             // transfer (e.g. CachePlugin)
             $this->remove($request);
         } else {
             if ($request->getParams()->get('queued_response')) {
                 // Queued responses do not need to be sent using curl
                 $this->remove($request);
                 $request->setState(RequestInterface::STATE_COMPLETE);
             } else {
                 // Add the request's curl handle to the multi handle
                 $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $this->createCurlHandle($request)->getHandle()));
             }
         }
     } catch (\Exception $e) {
         $this->removeErroredRequest($request, $e);
     }
 }
開發者ID:MicroSDHC,項目名稱:justinribeiro.com-examples,代碼行數:28,代碼來源:CurlMulti.php


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