Returns the available REST verbs

@param \Psr\Http\Message\ServerRequestInterface $request Request object
@param \Psr\Http\Message\ResponseInterface $response Response object
@return \Psr\Http\Message\ResponseInterface Modified response object
494680
public function options( ServerRequestInterface $request, ResponseInterface $response )
	{
		return $this->client->options( $request, $response );
	}
941579
public function checkElementKey(ServerRequest $request, Response $response): Response
    {
        $elementKey = $request->getQueryParams()['key'];

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

        $isAvailable = true;
        if ($storageRepository->loadElement('tt_content', $elementKey)) {
            $isAvailable = false;
        }

        return new JsonResponse(['isAvailable' => $isAvailable]);
    }
451639
public static function getResponseHeaders(ResponseInterface $response)
    {
        $responseHeaderArray = $response->getHeaders();

        /** @var string[] $responseHeaders */
        $responseHeaders = [];

        foreach ($responseHeaderArray as $key => $value) {
            $responseHeaders[strtolower($key)] = implode(',', $value);
        }

        return $responseHeaders;
    }
633357
public function getParametersFromResponse(ResponseInterface $response)
    {
        $contents = $response->getBody()->getContents();

        $parameters = [];

        parse_str($contents, $parameters);

        return $parameters;
    }
760389
protected function parseResponse(ResponseInterface $response)
    {
        $content = (string) $response->getBody();

        if(strpos($content, "callback") !== false){
            $lpos = strpos($content, "(");
            $rpos = strrpos($content, ")");
            $content  = substr($content, $lpos + 1, $rpos - $lpos -1);

            return $this->parseJson($content);
        } else if(strpos($content, "access_token=") !== false) {
            $result = array();
            parse_str($content, $result);
            return $result;
        } else {
            return parent::parseResponse($response);
        }
    }
618026
public static function getTransferredSize(ServerRequestInterface $request, ResponseInterface $response): string
    {
        return (string) (self::getMessageSize($request, 0) + self::getMessageSize($response, 0)) ?: '-';
    }
897507
protected function handleResponse(ResponseInterface $response)
    {
        $status = $response->getStatusCode();

        $data = (string) $response->getBody();
        $jsonResponseData = json_decode($data, false);
        $body = $data && $jsonResponseData === null ? $data : $jsonResponseData;

        return ['status_code' => $status, 'body' => $body];
    }
1040605
public static function responseToString(ResponseInterface $response): string
    {
        $reasonPhrase = $response->getReasonPhrase();
        $headers = self::serializeHeaders($response->getHeaders());
        $body = (string) $response->getBody();
        $format = 'HTTP/%s %d%s%s%s';
        if (! empty($headers)) {
            $headers = self::EOL . $headers;
        }
        $headers .= self::EOL . self::EOL;

        return sprintf(
            $format,
            $response->getProtocolVersion(),
            $response->getStatusCode(),
            ($reasonPhrase ? ' ' . $reasonPhrase : ''),
            $headers,
            $body
        );
    }
596851
public function create(ServerRequest $request, Response $response)
    {
        $className = $this->getControllerClass($request);
        if (!$className) {
            $this->missingController($request);
        }
        $reflection = new ReflectionClass($className);
        if ($reflection->isAbstract() || $reflection->isInterface()) {
            $this->missingController($request);
        }

        /** @var \Cake\Controller\Controller $controller */
        $controller = $reflection->newInstance($request, $response);

        return $controller;
    }
890708
private function responseView(ServerRequestInterface $request, ResponseInterface $response)
    {
        $ctx   = Context::mustGet();
        $views = ViewRegister::getViews();

        // the info of view model
        $controllerClass  = $ctx->get('controllerClass');
        $controllerAction = $ctx->get('controllerAction');

        $actionId = $controllerClass . '@' . $controllerAction;
        if (!isset($views[$actionId])) {
            return $response;
        }

        // Get layout and template
        [$layout, $template] = $views[$actionId];

        // accept and the of response
        $accepts       = $request->getHeader('accept');
        $currentAccept = \current($accepts);

        /* @var \Swoft\Http\Message\Response $response */
        $responseAttribute = AttributeEnum::RESPONSE_ATTRIBUTE;

        $data = $response->getAttribute($responseAttribute);

        // the condition of view
        $isTextHtml = !empty($currentAccept) && $response->isMatchAccept($currentAccept, 'text/html');
        $isTemplate = $controllerClass && $response->isArrayable($data) && $template;

        // show view
        if ($isTextHtml && $isTemplate) {
            if ($data instanceof Arrayable) {
                $data = $data->toArray();
            }

            /* @var \Swoft\View\Renderer $view */
            $view     = \Swoft::getBean('view');
            $content  = $view->render($template, $data, $layout);
            $response = $response
                ->withContent($content)
                ->withAttribute($responseAttribute, null)
                ->withoutHeader('Content-Type')->withAddedHeader('Content-Type', 'text/html');
        }

        return $response;
    }
844196
protected function fetchCorreiosServices(Response $response)
    {
        $xml = simplexml_load_string($response->getBody()->getContents());
        $results = json_decode(json_encode($xml->Servicos))->cServico;

        if (! is_array($results)) {
            return [get_object_vars($results)];
        }

        return array_map('get_object_vars', $results);
    }
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]);
    }
316197
public function run(ServerRequestInterface $request, ResponseInterface $response)
    {
        $route = $request->getAttribute('route');
        $callback = !empty($route->fn) ? $route->fn : null;

        if (!is_callable($callback)) {
            trigger_error("'fn' property of route shoud be a callable", E_USER_NOTICE);
            return $this->notFound($request, $response);
        }

        return $callback($request, $response);
    }
568508
public static function getResponseLine(ResponseInterface $response): string
    {
        return sprintf(
            '%s %d%s',
            self::getProtocol($response),
            self::getStatus($response),
            ($response->getReasonPhrase() ? ' '.$response->getReasonPhrase() : '')
        );
    }
783867
protected function serializeResponse($response)
    {
        /** @var ResponseInterface $response */
        $serialized = serialize([
            $response->getStatusCode(),
            $response->getHeaders(),
            $response->getBody()->getContents(),
        ]);

        //subsequent calls need to access the stream from the beginning
        $response->getBody()->rewind();

        return $serialized;
    }
1201851
protected function deserializeResponse(ResponseInterface $response)
    {
        // First, we need an encoder that filters out null values.
        $encoders = [new JsonEncoder()];

        // Attempt normalizing each key in this order, including denormalizing recursively.
        $extractor = new NotificationTypeExtractor();
        $extractor->setClass($this->service->getClass());
        $normalizers = [
            new UnixMillisecondNormalizer(),
            new UriNormalizer(),
            new ObjectNormalizer(null, null, null, $extractor),
            new ArrayDenormalizer(),
        ];

        $serializer = new Serializer($normalizers, $encoders);
        // @todo Handle exception returns.
        return $serializer->deserialize($response->getBody(), Notification::class.'[]', 'json');
    }
1021278
protected function setPsrResponse( \Psr\Http\Message\ResponseInterface $response )
	{
		$this->response->setStatus( $response->getStatusCode() );

		foreach( $response->getHeaders() as $key => $value ) {
			foreach( (array) $value as $val ) {
				$this->response->setHeader( $key, $val );
			}
		}

		return (string) $response->getBody();
	}