public function handle(ServerRequestInterface $request, ServerFrameInterface $frame) : ResponseInterface { try { return $frame->next($request); } catch (\Throwable $exception) { return $frame->factory()->createResponse(500, [], $this->debug ? $exception : "Internal Server Error"); } }
public function handle(ServerRequestInterface $request, ServerFrameInterface $frame) : ResponseInterface { $uri = $request->getUri(); if (strtolower($uri->getScheme()) !== 'https') { return $frame->factory()->createResponse(301, ["Location" => $uri->withScheme('https')]); } $response = $frame->next($request); $suffix = $this->includeSubdomains ? ';includeSubDomains' : ''; return $response->withHeader("Strict-Transport-Security", "max-age=" . $this->maxAge . $suffix); }
public function handle(ServerRequestInterface $request, ServerFrameInterface $frame) : ResponseInterface { $response = $frame->next($request); if ($response->hasHeader("Content-Encoding") || !$this->isAcceptableServerRequest($request)) { // Do not double-encode return $response; } $response = $response->withHeader('Content-Encoding', 'gzip'); $stream = $response->getBody(); return $response->withBody($frame->factory()->createStream(gzcompress($stream))); }