@param ServerRequestInterface $request
@param ResponseInterface $response
@param string[] $methods

@return ResponseInterface
342689
public function handleNotAllowed(ServerRequestInterface $request, ResponseInterface $response, array $methods)
    {
        $status = ($request->getMethod() === 'OPTIONS') ? 200 : 405;

        $contents = [
            'message' => 'Method not allowed',
            'status' => $status,
            'allowed_methods' => implode(', ', $methods),
        ];

        return $this
            ->withHTML($response, $contents)
            ->withStatus($status);
    }
265469
public function checkFieldKey(ServerRequest $request, Response $response): Response
    {
        $queryParams = $request->getQueryParams();
        $fieldKey = $queryParams['key'];
        $table = 'tt_content';
        if (isset($queryParams['table'])) {
            $table = $queryParams['table'];
        }

        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
        $storageRepository = $objectManager->get(StorageRepository::class);

        // check if fieldKey is available for this table
        $isAvailable = true;
        if ($storageRepository->loadField($table, $fieldKey)) {
            $isAvailable = false;
        }

        return new JsonResponse(['isAvailable' => $isAvailable]);
    }
52957
public function handleNotAllowed(ServerRequestInterface $request, ResponseInterface $response, array $methods)
    {
        $status = ($request->getMethod() === 'OPTIONS') ? 200 : 405;

        $detail = "Allowed methods: " . implode(', ', $methods);
        $extensions = [
            'allowed_methods' => $methods,
        ];

        $problem = new HTTPProblem($status, $detail, $extensions);
        return $this->renderProblem($response, $this->renderer, $problem);
    }
256258
public function executeMiddlewares(
        ServerRequestInterface $request,
        ResponseInterface $response,
        callable $next = null
    ) : ResponseInterface {
        return $this->getMiddlewares()->__invoke($request, $response, $next);
    }
283276
public function call(string $method, RequestInterface $request, $responseClass)
    {
        $serializer = $this->getSerializer();

        $req = $res = null;

        try {
            $req = $serializer->normalize($request, 'json');

            $res = $this->request('POST', $method, [
                'json' => $req,
            ]);

            $parts = $this->parseResponse($res->getBody()->getContents());

            /** @var ResponseInterface $response */
            $response = null;
            foreach ($parts as $part) {
                if ($part['headers']['Content-ID'] === '<jsonInfos>') {
                    $response = $this->serializer->deserialize($part['body'], $responseClass, 'json');
                } elseif ($response) {
                    $response->addAttachment(
                        new Attachment(trim($part['headers']['Content-ID'], '<>'), $part['body'])
                    );
                }
            }

            return $response->setSuccess(true);
        } catch (\GuzzleHttp\Exception\ClientException $exception) {
            $response = new $responseClass;
            if (null !== $res = $exception->getResponse()) {
                $data = json_decode($res->getBody()->getContents(), true);
                if (isset($data['messages']) && !empty($data['messages'])) {
                    foreach ($data['messages'] as $m) {
                        $response->addMessage(new Message(intval($m['id']), $m['type'], $m['messageContent']));
                    }
                }
                return $response;
            }

            throw $exception;
        } catch (\Exception $exception) {
            $exception = new ClientException('REST call failed', 0, $exception);

            if ($this->debug && $req) {
                $exception->request = $req;
            }
            if ($this->debug && $res) {
                $exception->response = $res;
            }

            throw $exception;
        }
    }
442851
protected function _redirect(ServerRequest $request, Response $response) {
		$message = $request->getSession()->consume($this->_config['flashKey']);
		$url = $response->getHeader('Location')[0];
		$status = $response->getStatusCode();

		$json = JsonEncoder::encode([
			// Error and content are here to make the output the same as previously
			// with the component, so existing unit tests don't break.
			'error' => null,
			'content' => null,
			'_message' => $message,
			'_redirect' => compact('url', 'status'),
		], $this->_config['jsonOptions']);

		$response = $response->withStatus(200)
			->withoutHeader('Location')
			->withHeader('Content-Type', 'application/json; charset=' . $response->getCharset())
			->withStringBody($json);

		return $response;
	}
155261
public function handle(
        ServerRequestInterface $request,
        ResponseInterface $response = null,
        $catch = self::DEFAULT_ERROR_CATCH
    )
    {
        /** @var ResponseInterface $response */
        // Passes the request to the container
        if (!$this->getContainer()->has(ServerRequestInterface::class)) {
            $this->getContainer()->share(ServerRequestInterface::class, $request);
        }

        //inject request content type
        $contentType = ServerRequestFactory::getHeader('content-type', $this->getRequest()->getHeaders(), '');
        $this->setContentType($contentType);

        if ($response === null) {
            $response = $this->getResponse();
        }

        $applicationEvent = $this->getApplicationEvent();
        $applicationEvent->setRequest($request);
        $applicationEvent->setResponse($response);

        try {
            $response = $this->handleResponse($this->handleRequest($request), $response);
        }catch (\Exception $exception){
            $notFoundException = $exception instanceof NotFoundException;
            $response = $this->handleError($exception, $request, $response, $catch)
                ->withStatus($notFoundException ? 404 : 500);
        }

        // validate response
        $response = $this->validateContract($response, ResponseInterface::class);

        // update content type
        $this->setContentType(ServerRequestFactory::getHeader('content-type', $response->getHeaders(), ''));

        return $response;
    }
1159471
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);
        $code = $response->getStatusCode();
        $allowedCodes = array_keys($this->renderer) + array_keys($this->defaultErrors);
        if (in_array($code, $allowedCodes)) {
            if (!$response->getBody()->getSize()) {
                $format = FormatNegotiator::getPreferredFormat($request);

                if (isset($this->renderer[$code])) {
                    $content = $this->renderer[$code]($format);
                } else {
                    $content = $this->defaultRenderer($code, $format);
                }

                if (is_array($content)) {
                    $content = json_encode($content);
                }

                $body = $this->streamFactory->createStream($content);

                $response = $response->withBody($body);
                $response = $response->withStatus($code);

                if ($format === 'json') {
                    $response = $response->withHeader('content-type', 'application/json');
                } else {
                    $response = $response->withHeader('content-type', 'text/html; charset=utf-8');
                }
            }
        }

        return $response;
    }
689779
public function handleRequest(ServerRequestInterface $request): ResponseInterface
    {
        $this->request = $request;
        $action = $request->getQueryParams()['action'] ?? $request->getParsedBody()['action'] ?? 'overview';
        $this->initializeView($action);

        $result = call_user_func_array([$this, $action . 'Action'], [$request]);
        if ($result instanceof ResponseInterface) {
            return $result;
        }
        $this->moduleTemplate->setContent($this->view->render());
        return new HtmlResponse($this->moduleTemplate->renderContent());
    }
170255
public function execute(ServerRequestInterface $request, ResponseInterface $response) : ResponseInterface {
		$httpRequestResponse = new HTTPRequestResponseContainer($request, $response);

		$this->dispatchRequestFilters($httpRequestResponse);

		$this->dispatchResponseFilters($httpRequestResponse);

		return $httpRequestResponse->getResponse();
	}
319056
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
	{
		$requestMethod = $request->getMethod();
		$method = $this->getOverrideMethod($requestMethod, $request);

		if (!empty($method) && $method !== $requestMethod) {
			$allowed = $this->getAllowedOverrideMethods($requestMethod);
			if ([] !== $allowed) {
				if (\in_array($method, $allowed, true)) {
					$request = $request->withMethod($method);
				} else {
					return Factory::response(405);
				}
			}
		}

		return $handler->handle($request);
	}
137550
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);

        return $this->withStaticHeaders($response, $this->headers);
    }
732102
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $stack = new Stack(
            $this->handlers,
            $this->handlerResolver
        );
        return $stack->handle($request);
    }
643691
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
    {
        $result    = $request->getAttribute(CommandDispatcher::ATTRIBUTE);
        $operation = $this->getOperation($request);

        return Factory::createResponse($this->okStatusResolver->resolve($result, $operation))
            ->withBody($this->createStringStream($this->bodySerializer->serialize($result)))
            ->withHeader('Content-Type', $this->bodySerializer->getContentType());
    }
74158
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $route = $this->routerDispatcher->dispatch($request);
        if (count($route->getAttributes())) {
            foreach ($route->getAttributes() as $key => $value) {
               $request = $request->withAttribute($key, $value);
            }
        }
        $request = $request->withAttribute('route', $route);

        return $handler->handle($request);
    }
1234981
private function makeMethodNotAllowedResponse(array $methods, Request $request): Promise {
        return call(function () use ($methods, $request) {
            /** @var \Amp\Http\Server\Response $response */
            $response = yield $this->errorHandler->handleError(Status::METHOD_NOT_ALLOWED, null, $request);
            $response->setHeader("allow", \implode(", ", $methods));
            return $response;
        });
    }
261021
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);
        $response = $this->responseView($request, $response);

        return $response;
    }