This method is invoked right after this request is sent.
The method will invoke [[Client::afterSend()]] and trigger the [[EVENT_AFTER_SEND]] event.
@param Response $response received response instance.
@since 2.0.1
771593
public function afterSend($response)
    {
        $this->client->afterSend($this, $response);

        $event = new RequestEvent();
        $event->request = $this;
        $event->response = $response;
        $this->trigger(self::EVENT_AFTER_SEND, $event);
    }
197246
private function send(RequestInterface $request, ResponseInterface $response)
    {
        // Send headers if no headers has been sent before this
        if (!headers_sent()) {
            // Send headers
            $this->sendHeaders($response);
        }

        // Check if we have any content to flush
        if (ob_get_level() > 1) {
            // Flush (send) the buffer that contains output that the application has generated
            while (ob_get_level() >= $this->outputBufferLevel) {
                ob_end_flush();
            }
        }

        // Set buffer level to null
        $this->outputBufferLevel = null;

        // Make sure it wasn't a HEAD request
        if ($request->getMethod() !== 'HEAD') {
            // Send the body to the client by echoing it
            echo $response->getBody();
        }
    }
1080875
public function onAfterRespond(Event $event)
    {
        /** @var ResponseInterface $response */
        $response = $event['response'];

        if (strpos($response->getHeaderLine('Content-Type'), 'html') === false) {
            DebuggerHelper::disableConsole();
        }
    }
67382
public function processResponse(ResponseInterface $response)
    {
        if (!$response instanceof Response
            || !$this->getRequest()
        ) {
            return;
        }

        $response = $this->handleResponse($response);
        $this->renderResponse($response);
        $this->terminateApp();
    }
950373
public function send($override = false)
	{
		if ($this->sent && !$override)
		{
			throw new ResponseAlreadySentException('Response has already been sent');
		}

		// Call trigger
		$dispatcher = EventManager::dispatcher("onResponseSend");
		if( !$dispatcher->isRun() )
		{
			// fixed json
			$dispatcher->dispatch(new ResponseSendEvent($this));
		}

		// Send our response data
		$this->sendHeaders();
		$this->sendBody();

		// Lock the response from further modification
		$this->lock();

		// Mark as sent
		$this->sent = true;

		// If there running FPM, tell the process manager to finish the server request/response handling
		if (function_exists('fastcgi_finish_request'))
		{
			fastcgi_finish_request();
		}

		$dispatcher->complete();

		return $this;
	}
1306643
public static function onRequest($request, $response) {
		$request = new Request($request);
		$request->setCookieHandler([$response, 'cookie']);
		$response = new Response($response);
		Container::getInstance()
			->get(Dispatcher::class)
			->handleRequest($request, $response);
	}
968238
private function whenSuccess($response, $method)
    {
        $this->makeSession($response, $method);
        return $this->result->setData([
            'success' => true,
            'payload' => [
                'redirect' => sprintf('%s%s', $this->baseUrl(), 'pagseguro/direct/success')
            ]
        ]);
    }
917732
private function shouldSendDataOnNextPage(ResponseInterface $response): bool
    {
        $status_code = $response->getStatusCode();

        return $status_code === self::STATUS_FOUND || $status_code === self::STATUS_MOVED_PERMANENTLY;
    }
1267202
public function intercept(ResponseInterface $response)
    {
        $this->transaction->response = $response;
        $this->transaction->exception = null;
        $this->stopPropagation();
    }
1188908
public function beforeSend()
    {
        $this->client->beforeSend($this);

        $event = new RequestEvent();
        $event->request = $this;
        $this->trigger(self::EVENT_BEFORE_SEND, $event);
    }
375583
public function respond($response = array(), $replaceResponse = false)
    {
        // Set any final data
        $this->set($response, $replaceResponse);

        // Make sure it only responds once
        if ($this->hasResponded()) {
            return;
        }

        // Clear anything that may have snuck in
        $this->cleanBuffer();

        if (self::$code == 204) {
            // No-body response
            $this->responseSent = true;
            return;
        }

        if (!empty($this->apiResponseCallback) && is_callable($this->apiResponseCallback)) {
            $callback = &$this->apiResponseCallback;
            $callback($this->response);
        }

        // Format for specific output type
        if ($this->responseFormat == 'JSON') {
            if ($this->jsonCallbackWrap) {
                echo $this->jsonCallbackWrap . '(';
            }

            echo json_encode($this->response);

            if ($this->jsonCallbackWrap) {
                echo ');';
            }
        } else {
            throw new \Exception('Invalid response format: '. $this->responseFormat);
        }

        // Indicate the response as already sent
        $this->responseSent = true;
    }
1007736
public function middleware($request, &$response)
    {
        $that = $this;
        if ($middleware = current($this->middleware)) {
            next($this->middleware);
            $middleware->next($request, $response, function ($request, $response) use ($that) {
                $that->middleware($request, $response);
            });
        }
    }
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;
    }
556449
private function setErrorFromResponse(Response $response)
    {
        $this->statusCode = $response->getStatus();
        $body = $response->getBody();
        if (isset($body['ErrorInfo'])) {
            $this->errorInfo = $body['ErrorInfo'];
        }
        if (isset($body['ErrorMessage'])) {
            $this->errorMessage = $body['ErrorMessage'];
        }
        if (isset($body['ErrorIdentifier'])) {
            $this->errorIdentifier = $body['ErrorIdentifier'];
        }
    }
442047
public function onKernelResponse(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $routeName = $request->attributes->get('_route');
        if (!$route = $this->app['routes']->get($routeName)) {
            return;
        }

        foreach ((array) $route->getOption('_after_middlewares') as $callback) {
            $response = call_user_func($this->app['callback_resolver']->resolveCallback($callback), $request, $event->getResponse(), $this->app);
            if ($response instanceof Response) {
                $event->setResponse($response);
            } elseif (null !== $response) {
                throw new \RuntimeException(sprintf('An after middleware for route "%s" returned an invalid response value. Must return null or an instance of Response.', $routeName));
            }
        }
    }
847398
protected function sendHeaders(Response $response)
    {
        // Send HTTP status & reason-phrase
        header(
            sprintf(
                '%s %s %s',
                $this->getProtocolLine(),
                $response->getStatusCode(),
                $response->getReasonPhrase()
            ),
            true,
            $response->getStatusCode()
        );

        // Send headers
        $headers = $response->getHeaders();
        foreach ($headers as $name => $valueCollection) {
            foreach ($valueCollection as $value) {
                header(sprintf('%s: %s', $name, $value), false);
            }
        }
    }
121692
public function sendResponseBody(ResponseInterface $response):void
    {
        if (($body = $response->getBody()->detach()) === null) {
            $body = $response->getBody()->__toString();
        }
        $this->sendBody($body);
    }