コード例 #1
0
ファイル: RedirectSubscriber.php プロジェクト: lamenath/fbp
 /**
  * On post send event.
  *
  * @param \Ivory\HttpAdapter\Event\PostSendEvent $event The event.
  */
 public function onPostSend(PostSendEvent $event)
 {
     try {
         $redirectRequest = $this->redirect->createRedirectRequest($event->getResponse(), $event->getRequest(), $event->getHttpAdapter());
     } catch (HttpAdapterException $e) {
         $event->setException($e);
         return;
     }
     if ($redirectRequest === false) {
         $this->redirect->prepareResponse($event->getResponse(), $event->getRequest());
         return;
     }
     try {
         $event->setResponse($event->getHttpAdapter()->sendRequest($redirectRequest));
     } catch (HttpAdapterException $e) {
         $event->setException($e);
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function sendInternalRequest(InternalRequestInterface $internalRequest)
 {
     try {
         $this->eventDispatcher->dispatch(Events::PRE_SEND, $preSendEvent = new PreSendEvent($this, $internalRequest));
         $response = parent::sendInternalRequest($preSendEvent->getRequest());
         $this->eventDispatcher->dispatch(Events::POST_SEND, $postSendEvent = new PostSendEvent($this, $preSendEvent->getRequest(), $response));
         if ($postSendEvent->hasException()) {
             throw $postSendEvent->getException();
         }
         $response = $postSendEvent->getResponse();
     } catch (HttpAdapterException $e) {
         $e->setRequest($internalRequest);
         $e->setResponse(isset($response) ? $response : null);
         $this->eventDispatcher->dispatch(Events::EXCEPTION, $exceptionEvent = new ExceptionEvent($this, $e));
         if ($exceptionEvent->hasResponse()) {
             return $exceptionEvent->getResponse();
         }
         throw $exceptionEvent->getException();
     }
     return $response;
 }
コード例 #3
0
 /**
  * On post send event.
  *
  * @param \Ivory\HttpAdapter\Event\PostSendEvent $event Th post send event.
  */
 public function onPostSend(PostSendEvent $event)
 {
     $event->setRequest($this->record($event->getRequest(), $event->getResponse()));
 }
コード例 #4
0
 /**
  * On post send event.
  *
  * @param \Ivory\HttpAdapter\Event\PostSendEvent $event The event.
  */
 public function onPostSend(PostSendEvent $event)
 {
     $this->stopwatch->stop($this->getStopwatchName($event->getHttpAdapter(), $event->getRequest()));
 }
コード例 #5
0
ファイル: CookieSubscriber.php プロジェクト: lamenath/fbp
 /**
  * On post send event.
  *
  * @param \Ivory\HttpAdapter\Event\PostSendEvent $event The post send event.
  */
 public function onPostSend(PostSendEvent $event)
 {
     $this->cookieJar->extract($event->getRequest(), $event->getResponse());
 }
コード例 #6
0
ファイル: AbstractHttpAdapter.php プロジェクト: lamenath/fbp
 /**
  * Sends an internal request.
  *
  * @param \Ivory\HttpAdapter\Message\InternalRequestInterface $internalRequest The internal request.
  *
  * @throws \Ivory\HttpAdapter\HttpAdapterException If an error occurred.
  *
  * @return \Ivory\HttpAdapter\Message\ResponseInterface The response.
  */
 private function sendInternalRequest(InternalRequestInterface $internalRequest)
 {
     try {
         if ($this->configuration->hasEventDispatcher()) {
             $this->configuration->getEventDispatcher()->dispatch(Events::PRE_SEND, $preSendEvent = new PreSendEvent($this, $internalRequest));
             $internalRequest = $preSendEvent->getRequest();
         }
         $response = $this->doSendInternalRequest($internalRequest);
         if ($this->configuration->hasEventDispatcher()) {
             $this->configuration->getEventDispatcher()->dispatch(Events::POST_SEND, $postSendEvent = new PostSendEvent($this, $preSendEvent->getRequest(), $response));
             if ($postSendEvent->hasException()) {
                 throw $postSendEvent->getException();
             }
             $response = $postSendEvent->getResponse();
         }
     } catch (HttpAdapterException $e) {
         $e->setRequest($internalRequest);
         $e->setResponse(isset($response) ? $response : null);
         if ($this->configuration->hasEventDispatcher()) {
             $this->configuration->getEventDispatcher()->dispatch(Events::EXCEPTION, $exceptionEvent = new ExceptionEvent($this, $e));
             if ($exceptionEvent->hasResponse()) {
                 return $exceptionEvent->getResponse();
             }
             $e = $exceptionEvent->getException();
         }
         throw $e;
     }
     return $response;
 }
 /**
  * On post send event.
  *
  * @param \Ivory\HttpAdapter\Event\PostSendEvent $event The post send event.
  */
 public function onPostSend(PostSendEvent $event)
 {
     $this->collectResponse($event->getHttpAdapter(), $event->getRequest(), $event->getResponse());
 }
コード例 #8
0
ファイル: LoggerSubscriber.php プロジェクト: KGalley/whathood
 /**
  * On post send event.
  *
  * @param \Ivory\HttpAdapter\Event\PostSendEvent $event The post send event.
  */
 public function onPostSend(PostSendEvent $event)
 {
     $event->setRequest($this->debug($event->getHttpAdapter(), $event->getRequest(), $event->getResponse()));
 }
コード例 #9
0
 /**
  * On post send event.
  *
  * @param \Ivory\HttpAdapter\Event\PostSendEvent $event The event.
  */
 public function onPostSend(PostSendEvent $event)
 {
     if (!$this->statusCode->validate($event->getResponse())) {
         $event->setException($this->createStatusCodeException($event->getResponse(), $event->getRequest(), $event->getHttpAdapter()));
     }
 }