Log the response.

@param IEvent $event
@param string $response

@return IEvent
185054
public function end(IEvent $event, $response)
    {
        $endTimestamp = microtime(true);

        $event->setResponse($response);
        $event->setLatency($endTimestamp - $this->startTimestamp);

        return $this->adapter->save($event);
    }
1078040
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        if (!preg_match(static::USER_AGENT_REGEX, $event->getRequest()->headers->get('User-Agent'))) {
            $this->sendHeaders = false;
            $this->headers = [];

            return;
        }

        $this->response = $event->getResponse();
        foreach ($this->headers as $header => $content) {
            $this->response->headers->set($header, $content);
        }
        $this->headers = [];
    }
1002135
public function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        if (!$this->keyExtractor->hasKey($request)) {
            $response = new Response();
            $response->setStatusCode(401);
            $event->setResponse($response);
            return ;
        }

        $apiKey = $this->keyExtractor->extractKey($request);

        $token = new ApiKeyUserToken();
        $token->setApiKey($apiKey);

        try {
            $authToken = $this->authenticationManager->authenticate($token);
            $this->tokenStorage->setToken($authToken);

            return;
        } catch (AuthenticationException $failed) {
            $token = $this->tokenStorage->getToken();
            if ($token instanceof ApiKeyUserToken && $token->getCredentials() == $apiKey) {
                $this->tokenStorage->setToken(null);
            }

            $message = $failed->getMessage();
        }

        $response = new Response();
        $response->setContent($message);
        $response->setStatusCode(403);
        $event->setResponse($response);
    }
459132
public function trigger(Event $event): ResponseCollection
    {
        $response = new ResponseCollection();

        $queue = $this->getListeners($event->getName());

        $queue->merge($this->getListeners(Event::EVENT_ALL));

        foreach ($queue as $listener) {
            /* @var $listener EventListener */

            $callback = $listener->getCallback();

            if (empty($callback) || !is_callable($callback)) {
                // @todo detach listener
                continue;
            }

            $response->push(
                call_user_func($callback, $event)
            );

            if ($event->isPropagationStopped()) {
                break;
            }
        }

        return $response;
    }
945759
public function processClose($event)
    {
        $response = new Response();
        $response->opcode = Request::OPCODE_CLOSE;
        return $event->sender->close($response);
    }
1306307
public function processResponse(ResponseInterface $response, SystemEvent $event)
    {
        if ($event->getName() === SystemEvent::FINISH) {
            $event->stopPropagation(true);
            $server  = $this->getServer();
            $emitter = $server->getEmitter();
            $emitter->emit($response);

            return;
        }
        $events = $this->getEvents();
        $event->setResult(SystemEvent::FINISH, $response);
        $events->trigger($event(SystemEvent::FINISH));
    }
1001770
public function httpGet(RequestInterface $request, ResponseInterface $response)
    {
        $path = $request->getPath();

        try {
            $node = $this->server->tree->getNodeForPath($path);
        } catch (DAV\Exception\NotFound $e) {
            return;
        }

        if (!$node instanceof INode) {
            return;
        }

        $writer = $this->server->xml->getWriter();
        $writer->contextUri = $this->server->getBaseUri();
        $writer->openMemory();
        $writer->startDocument('1.0', 'UTF-8');
        $writer->startElement('{http://calendarserver.org/ns/}notification');
        $node->getNotificationType()->xmlSerializeFull($writer);
        $writer->endElement();

        $response->setHeader('Content-Type', 'application/xml');
        $response->setHeader('ETag', $node->getETag());
        $response->setStatus(200);
        $response->setBody($writer->outputMemory());

        // Return false to break the event chain.
        return false;
    }
857517
public function serve(ResponseInterface $response, $cookies = [])
    {
        if (headers_sent($file, $line)) {
            throw new HeadersSentException(
                'Headers already sent in ' . $file . ' on line ' . $line
            );
        }
        $this->triggerEvent('serve', new \Jivoo\Event($this, [
            'response' => $response,
            'cookies' => $cookies
        ]));
        $this->serveStatus($response);
        $this->serveCookies($cookies);
        $this->serveHeaders($response);
        $this->serveBody($response, $this->compression);
        $this->triggerEvent('served', new \Jivoo\Event($this, [
            'response' => $response,
            'cookies' => $cookies
        ]));
    }
563474
public function event(Closure $event)
    {
        if (null !== $response = $event()) {
            $this->resolveEventResponse($response);
        }

        return $this;
    }
501798
public function onKernelResponse(FilterResponseEvent $event)
	{
		$result = parent::onKernelResponse($event);
		$content = ob_get_contents();

		if ($this->request_stack->getCurrentRequest()->getMethod() === 'POST' && empty($content))
		{
			$event->stopPropagation();
		}

		return $result;
	}
895925
public function onRequestSent(Event $event)
    {
        $request = $event['request'];
        $response = $event['response'];
        $handle = $event['handle'];

        if ($wire = $request->getParams()->get('request_wire')) {
            $request = clone $request;
            $request->setBody($wire);
        }

        if ($wire = $request->getParams()->get('response_wire')) {
            $response = clone $response;
            $response->setBody($wire);
        }

        // Send the log message to the adapter, adding a category and host
        $priority = $response && $response->isError() ? LOG_ERR : LOG_DEBUG;
        $message = $this->formatter->format($request, $response, $handle);
        $this->logAdapter->log($message, $priority, array(
            'request'  => $request,
            'response' => $response,
            'handle'   => $handle
        ));
    }
97913
private function buildResponse($event, $response) {
        $success = !$response->hasErrors();
        $duplicate = ($response->code == 409);
        $statusCode = $response->code;
        $errorMessage = null;
        if ($response->code == 401) {
            $errorMessage = 'Unauthorised. Please check your Project Id and API Key';
        }
        if ($response->body != null && $response->body->errorMessage != null) {
            $errorMessage = $response->body->errorMessage;
        }
        return new Response($success, $duplicate, $statusCode, $errorMessage, $event);
    }
214046
private function handleResponse($response)
    {
        if ($response instanceof PagedListResponse || $response instanceof GaxPagedListResponse) {
            $response = $response->getPage()->getResponseObject();
        }

        if ($response instanceof Message) {
            return $this->serializer->encodeMessage($response);
        }

        if ($response instanceof OperationResponse || $response instanceof GaxOperationResponse) {
            return $response;
        }

        if ($response instanceof ServerStream || $response instanceof GaxServerStream) {
            return $this->handleStream($response);
        }

        return null;
    }
261412
public function afterScanUrl(Event $event, Response $response)
    {
        if (!$this->args->getOption('verbose')) {
            return true;
        }

        $method = $response->isOk() ? 'success' : ($response->isRedirect() ? 'warning' : 'error');
        $message = $response->isOk() ? __d('link-scanner', 'OK') : (string)$response->getStatusCode();
        call_user_func([$this->io, $method], $message);

        return true;
    }
250583
public function getEventLog(Event $event, $eventName)
    {
        $eventLog = $this->getEventLogObject($this->getEventLogInfo($event, $eventName));

        if (null === $eventLog) {
            return null;
        }

        $eventLog->setTypeId($eventName);
        $eventLog->setIp($this->getClientIp());
        $eventLog->setEventTime(new \DateTime());
        $this->setUser($eventLog);

        return $eventLog;
    }
146960
protected function handleEvent($event)
    {
        if (!is_null($response = $this->call('event.*', array($event)))) {
            return $response;
        }

        $event['Event'] = strtolower($event['Event']);

        return $this->call("event.{$event['Event']}", array($event));
    }
380268
public function method($event, $request = [], Response $response = null)
    {
        if (is_array($request)) {
            $request = Request::i()->load()->setStage($request);
        }

        if (!($request instanceof Request)) {
            $request = Request::i()->load();
        }

        if (is_null($response)) {
            $response = Response::i()->load();
        }

        $this->trigger($event, $request, $response);

        if ($response->isError()) {
            return false;
        }

        return $response->getResults();
    }