Clean and fire onWsConnect().
@param Swoole\Request $request
@param Swoole\Response $response
1311
function afterResponse(Swoole\Request $request, Swoole\Response $response)
    {
        if ($request->isWebSocket())
        {
            $conn = array('header' => $request->header, 'time' => time());
            $this->connections[$request->fd] = $conn;

            if (count($this->connections) > $this->max_connect)
            {
                $this->cleanConnection();
            }

            $this->onWsConnect($request->fd, $request);
        }
        parent::afterResponse($request, $response);
    }
264295
public function terminate($request, $response)
    {
        if ($this->sessionHandled && $this->sessionConfigured() && ! $this->usingCookieSessions()) {
            $this->manager->driver()->save();
        }
    }
910027
public function handleRequest(Request $request, Response $response) {
		if ($this->static_enable) {
			$request->uri = $request->server['request_uri'];
			$uri = $request->server['request_uri'];
			if (strpos($uri, $this->static_prefix) === 0) {
				$uri = substr($uri, strlen($this->static_prefix));
			}
			$path = realpath($this->static_dir . $uri);
			if ($path !== false && strpos($path, $this->static_dir) === 0) {
				if ($this->executeInterceptor('before', $request, $response) !== null) {
					$request->end();
					$response->end();
					unset($request, $response);
					return;
				}
				$response->mimeType(pathinfo($path, PATHINFO_EXTENSION));
				$response->sendfile($path);
				$this->executeInterceptor('after', $request, $response);
				$request->end();
				$response->end();
				unset($request, $response);
				return;
			}
		}
		$this->router->parse($request);
		if ($this->executeInterceptor('before', $request, $response) !== null) {
			$request->end();
			$response->end();
			unset($request, $response);
			return;
		}
		$this->dispatch($request, $response);
	}
474654
public function execute(\Owl\Http\Request $request, \Owl\Http\Response $response)
    {
        if ($router = $this->getDelegateRouter($request)) {
            return $router->execute($request, $response);
        }

        try {
            if (!$handlers = $this->getMiddlewareHandlers($request)) {
                $this->respond($request, $response);
            } else {
                $handlers[] = function ($request, $response) {
                    $this->respond($request, $response);

                    yield true;
                };

                $this->middleware->execute([$request, $response], $handlers);
            }
        } catch (\Exception $exception) {
            if ($this->exception_handler) {
                call_user_func($this->exception_handler, $exception, $request, $response);
            } else {
                throw $exception;
            }
        } catch (\Throwable $error) {
            if ($this->exception_handler) {
                call_user_func($this->exception_handler, $error, $request, $response);
            } else {
                throw $error;
            }
        }

        return $response;
    }
724455
protected function sendResetLinkFailedResponse(Request $request, $response)
    {
        if ($request->expectsJson()) {
            return new JsonResponse([
                'message' =>  'The given data was invalid.',
                'errors' => [
                    'email' => trans($response)
                ]
            ], 422);
        }
        return back()->withErrors(
            ['email' => trans($response)]
        );
    }
1002061
public function terminate($request, $response)
    {
        $this->terminateMiddleware($request, $response);

        $this->app->terminate();
    }
878321
public function handleResponse(Request $request, Response $response)
    {
        if ($response->getStatusCode() == 422) {
            $errors = $response->getOriginalContent()['validation_errors'];

            throw new HttpResponseException(
                redirect()->back()->withInput($request->input())->withErrors($errors)
            );
        }

        if ($response->getStatusCode() == 403) {
            abort(403);
        }

        return $response->isNotFound() ? abort(404) : $response->getOriginalContent();
    }
1151216
public function applyPostInterceptors(Request $request, Response $response): bool
    {
        return $this->interceptors->postProcess($request, $response);
    }
160914
public function process(Request $request, Response $response)
    {
        // Conditionally add jQuery
        $this->addJquery($request, $response);

        /** @var FileAssetInterface $asset */
        foreach ($this->sort($this->javascript) as $key => $asset) {
            $this->processAsset($asset, $request, $response);
            unset($this->javascript[$key]);
        }

        /** @var FileAssetInterface $asset */
        foreach ($this->sort($this->stylesheet) as $key => $asset) {
            $this->processAsset($asset, $request, $response);
            unset($this->stylesheet[$key]);
        }
    }
346708
public function handleResponse(Response $response) : void
    {
        if ($this->id === null) {
            // The request was not associated with an existing session, and no session writes occurred.
            // Sending a session cookie is unnecessary.
            return;
        }

        // Note: we re-send the session cookie even if it was part of the request, to refresh the expiration time.

        $this->writeSessionId($response);
        $this->reset();
    }
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);
            });
        }
    }
860479
protected function sendResetLinkResponse(Request $request, $response)
    {
        if ($request->expectsJson()) {
            return response()->json([
                'status' => trans($response)
            ]);
        }
        return back()->with('status', trans($response));
    }
521791
public function postProcess(Request $request, Response $response): bool
    {
        foreach ($this->postInterceptors as $postInterceptor) {
            if (false === $this->executePostInterceptor($postInterceptor, $request, $response)) {
                return false;
            }
        }

        return true;
    }
1362466
public function log(Request $request, Response $response): void
    {
        $host = $request->url();
        $method = $request->method();
        $agent = $request->userAgent();
        $date = $this->date($response->getDate());
        $status = $response->status();
        $style = $this->style($status);

        $this->output->writeln(
            sprintf("%s %s %s <$style>%d</$style> %s", $host, $date, $method, $status, $agent)
        );
    }
637457
private void handleConnectResponse(ConnectResponse response, Throwable error, CompletableFuture<Connection> future) {
    if (open) {
      if (error == null) {
        LOGGER.trace("{} - Received {}", id, response);
        // If the connection was successfully created, immediately send a keep-alive request
        // to the server to ensure we maintain our session and get an updated list of server addresses.
        if (response.status() == Response.Status.OK) {
          selector.reset(response.leader(), response.members());
          future.complete(connection);
        } else {
          connect(future);
        }
      } else {
        LOGGER.debug("{} - Failed to connect! Reason: {}", id, error);
        connect(future);
      }
    }
  }
685419
private function doRun(RequestInterface $request, ResponseInterface $response): void
    {
        $throwable = null;

        foreach ($this->plugins as $plugin) {
            if ($plugin->onPreRequest($this, $request, $response)) {
                return;
            }
        }

        try {
            $this->handleRequest($request, $response);
        } catch (\Throwable $throwable) {
            $this->throwableToResponse($throwable, $response);
        }

        if ($response->getStatusCode()->isError()) {
            $this->handleError($request, $response, $throwable);
        }

        foreach ($this->plugins as $plugin) {
            if ($plugin->onPostRequest($this, $request, $response)) {
                return;
            }
        }
    }
20764
public function setRequestAllowance(RequestInterface $request, ResponseInterface $response)
    {
        $route = $this->getRoute($request);

        $remaining = $response->getHeader('X-RateLimit-Remaining');
        $reset     = $response->getHeader('X-RateLimit-Reset');
        if (empty($remaining) || empty($reset) || (int) $remaining[0] > 0) {
            return;
        }

        $this->routes[$route]['reset'] = $reset[0];
    }