Stops the stopwatch.

@param RequestInterface $request
@param ResponseInterface $response
424973
private function onRequestComplete(RequestInterface $request, ResponseInterface $response)
    {
        $hash = $this->hash($request);
        // Send the log message to the adapter, adding a category and host
        $priority = $response && $this->isError($response) ? LOG_ERR : LOG_DEBUG;
        $message = $this->formatter->format($request, $response);
        $event = $this->stopwatch->stop($hash);
        $this->logAdapter->log($message, $priority, array(
            'request'  => $request,
            'response' => $response,
            'time'     => $event->getDuration(),
        ));
    }
226264
private function canSave(RequestInterface $request, ResponseInterface $response)
    {
        if ($request->getMethod() !== 'GET') {
            return false;
        }

        if ($response->getStatusCode() !== 200) {
            return false;
        }

        if (!$this->appendQuery && !empty($request->getUri()->getQuery())) {
            return false;
        }

        if ($response->hasHeader('location')) {
            return false;
        }

        $cacheControl = $response->getHeaderLine('Cache-Control');

        if ($cacheControl && (stripos($cacheControl, 'no-cache') !== false || stripos($cacheControl, 'no-store') !== false)) {
            return false;
        }

        return true;
    }
984926
public function shutdown(ServerRequestInterface $request, $response)
    {
        $this->offsetUnset('request');
        $this->offsetUnset('response');

        unset($request, $response);

        return 0;
    }
383575
protected function terminateMiddleware(RequestContract $request, ResponseContract $response)
    {
        $middlewares = array_merge(
            $this->middleware,
            $request->matcher()->getCallerMiddleware()
        );

        foreach ($middlewares as $middleware) {
            if (! is_string($middleware)) {
                continue;
            }

            list($name) = $this->parseMiddleware($middleware);

            $instance = $this->app->make($name);

            if (method_exists($instance, 'terminate')) {
                $instance->terminate($request, $response);
            }
        }
    }
65938
protected function sendEvent(RequestInterface $request, ResponseInterface $response)
    {
        $key = $this->getEventKey($request);
        $event = $this->events[$key];

        unset($this->events[$key]);

        $event->setExecutionStop();
        $event->setResponse($response);
        $this->eventDispatcher->dispatch(GuzzleHttpEvent::EVENT_NAME, $event);
    }
755756
public function save(ResponseInterface $response)
    {
        $this->setStatusCode($response->getStatusCode());
        $this->setStatusPhrase($response->getReasonPhrase());
        $this->setBody($response->getBody()->getContents());

        // rewind to previous position after reading response body
        if ($response->getBody()->isSeekable()) {
            $response->getBody()->rewind();
        }

        $this->setHeaders($response->getHeaders());
        $this->setProtocolVersion($response->getProtocolVersion());
    }
621298
public function finishRequestProcess(RequestProcess $process, ResponseInterface $response = null)
    {
        if ($response) {
            $process->setResponse($response);
        }
        $this->requestStack[] = $process;
    }
1123596
public function terminate($request, $response)
    {
        if (! ($request = $this->app['request']) instanceof HttpRequest) {
            return;
        }

        // Laravel's route middlewares can be terminated just like application
        // middleware, so we'll gather all the route middleware here.
        // On Lumen this will simply be an empty array as it does
        // not implement terminable route middleware.
        $middlewares = $this->gatherRouteMiddlewares($request);

        // Because of how middleware is executed on Lumen we'll need to merge in the
        // application middlewares now so that we can terminate them. Laravel does
        // not need this as it handles things a little more gracefully so it
        // can terminate the application ones itself.
        if (class_exists(Application::class, false)) {
            $middlewares = array_merge($middlewares, $this->middleware);
        }

        foreach ($middlewares as $middleware) {
            if ($middleware instanceof Closure) {
                continue;
            }

            list($name, $parameters) = $this->parseMiddleware($middleware);

            $instance = $this->app->make($name);

            if (method_exists($instance, 'terminate')) {
                $instance->terminate($request, $response);
            }
        }
    }
1316579
private function cacheVary(
        RequestInterface $request,
        ResponseInterface $response
    ) {
        $key = $this->getVaryKey($request);
        $this->cache->save($key, $this->normalizeVary($response), $this->getTtl($response));
    }
876774
public function dispatch(RequestInterface $request, ResponseInterface $response = null)
    {
        if (!($request instanceof ConsoleRequest)) {
            throw new \RuntimeException('You can use this controller only from a console!');
        }

        return parent::dispatch($request, $response);
    }
785741
public function process(
        RequestInterface $request,
        ResponseInterface $response,
        DelegateInterface $next = null
    ) {
        try {
            if ($next) {
                return $next->next($request, $response);
            }
            return $response;
        } catch (\Exception $e) {
            return WhoopsRunner::handle($e, $request);
        }
    }
1097785
public function terminate($request, $response): void
    {
        if ($user = $request->user(request()->route('guard'))) {
            // We are using database queries rather than eloquent, to bypass triggering events.
            // Triggering update events flush cache and costs us more queries, which we don't need.
            $user->newQuery()->where($user->getKeyName(), $user->getKey())->update(['last_activity' => now()]);
        }
    }
465580
public function terminate( $request, $response )
	{
		if ( $this->sessionHandled && $this->sessionConfigured() && !$this->usingHandler( CookieSessionHandler::class ) )
			$this->driver()->save();
	}
189024
public function stop_request_timer() {
		if ( ! is_null( $this->request_start_time ) ) {
			$this->request_time += microtime( true ) - $this->request_start_time;
		}
		$this->request_start_time = null;
	}
455427
public function run(RequestInterface $request, ResponseInterface $response)
    {
        // Unused parameter
        unset($request);

        // Lock script, to ensure it can not be run twice  at the same time (before previous instance is done).
        $this->startLock();

        $climate = $this->climate();

        $processedCallback = function($success, $failures, $skipped) use ($climate) {
            if (!empty($success)) {
                $climate->green()->out(sprintf('%s emails were successfully sent.', count($success)));
            }

            if (!empty($failures)) {
                $climate->red()->out(sprintf('%s emails were not successfully sent', count($failures)));
            }

            if (!empty($skipped)) {
                $climate->dim()->out(sprintf('%s emails were skipped.', count($skipped)));
            }
        };

        $queueManager = new EmailQueueManager([
            'logger' => $this->logger,
            'queue_item_factory' => $this->queueItemFactory
        ]);
        $queueManager->setProcessedCallback($processedCallback);
        $queueManager->processQueue();

        $this->stopLock();

        return $response;
    }
992146
public function addSuccess(RequestInterface $request, ResponseInterface $response): void
    {
        $this->lastRequest = $request;
        $this->lastResponse = $response;
        $this->success = true;
    }
815000
private function add(
        RequestInterface $request,
        ResponseInterface $response = null
    ) {
        $this->transactions[] = ['request' => $request, 'response' => $response];
        if (count($this->transactions) > $this->limit) {
            array_shift($this->transactions);
        }
    }