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


PHP RequestInterface::setState方法代码示例

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


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

示例1: beforeSend

 /**
  * Prepare for sending
  *
  * @param RequestInterface $request Request to prepare
  * @throws \Exception on error preparing the request
  */
 protected function beforeSend(RequestInterface $request)
 {
     try {
         $state = $request->setState(RequestInterface::STATE_TRANSFER);
         if ($state == RequestInterface::STATE_TRANSFER) {
             $this->addHandle($request);
         } else {
             // Requests might decide they don't need to be sent just before
             // transfer (e.g. CachePlugin)
             $this->remove($request);
             if ($state == RequestInterface::STATE_COMPLETE) {
                 $this->successful[] = $request;
             }
         }
     } catch (\Exception $e) {
         // Queue the exception to be thrown when sent
         $this->removeErroredRequest($request, $e);
     }
 }
开发者ID:sharpspring,项目名称:guzzle3,代码行数:25,代码来源:CurlMulti.php

示例2: 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

示例3: beforeSend

 /**
  * Prepare for sending
  *
  * @param RequestInterface $request Request to prepare
  * @throws \Exception on error preparing the request
  */
 protected function beforeSend(RequestInterface $request)
 {
     try {
         $state = $request->setState(RequestInterface::STATE_TRANSFER);
         if ($state == RequestInterface::STATE_TRANSFER) {
             // Add the request curl handle to the multi handle
             $handle = $this->createCurlHandle($request)->getHandle();
             $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $handle));
         } else {
             // Requests might decide they don't need to be sent just before transfer (e.g. CachePlugin)
             $this->remove($request);
             if ($state == RequestInterface::STATE_COMPLETE) {
                 $this->successful[] = $request;
             }
         }
     } catch (\Exception $e) {
         // Queue the exception to be thrown when sent
         $this->removeErroredRequest($request, $e);
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:26,代码来源:CurlMulti.php

示例4: retryRequest

 /**
  * Trigger a request to retry
  *
  * @param RequestInterface $request Request to retry
  */
 protected function retryRequest(RequestInterface $request)
 {
     $params = $request->getParams();
     $retries = (int) $params->get(self::RETRY_PARAM) + 1;
     $params->set(self::RETRY_PARAM, $retries);
     // If this request has been retried too many times, then throw an exception
     if ($retries <= $this->maxRetries) {
         // Calculate how long to wait until the request should be retried
         $delay = call_user_func($this->delayClosure, $retries);
         $delayTime = microtime(true) + $delay;
         // Send the request again
         $request->setState(RequestInterface::STATE_TRANSFER);
         $params->set(self::DELAY_PARAM, $delay);
     }
 }
开发者ID:MicroSDHC,项目名称:justinribeiro.com-examples,代码行数:20,代码来源:ExponentialBackoffPlugin.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

示例6: beforeSend

protected function beforeSend(RequestInterface $request)
{
try {
$state = $request->setState(RequestInterface::STATE_TRANSFER);
if ($state == RequestInterface::STATE_TRANSFER) {

 $handle = $this->createCurlHandle($request)->getHandle();
$this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $handle));
} else {

 $this->remove($request);
if ($state == RequestInterface::STATE_COMPLETE) {
$this->successful[] = $request;
}
}
} catch (\Exception $e) {

 $this->removeErroredRequest($request, $e);
}
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:20,代码来源:CurlMulti.php


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