/** * 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); } }
/** * {@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; }
/** * 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())); }
/** * 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())); }
/** * 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()); }
/** * 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()); }
/** * 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())); }
/** * 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())); } }