Example #1
0
 /**
  * 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);
     }
 }