Sets desired type of response context

@param string $responseContextClass

@throws RequestContextException

@return RequestContext
497869
public function setResponseContextClass(string $responseContextClass): RequestContext
    {
        if (!is_a($responseContextClass, ResponseContextAbstract::class, true)) {
            throw new RequestContextException(
                sprintf(
                    "Class %s must have %s as one of its parents",
                    $responseContextClass, //@codeCoverageIgnore
                    ResponseContextAbstract::class
                )
            );
        }

        $this->responseContextClass = $responseContextClass;

        return $this;
    }
1223929
public function updateContext(Context\Context $reqBody) {
        try {
            $url = $this->url . "updateContext";
            return $this->restRequest($url, 'POST', $reqBody->get())->getResponseBody();
        } catch (\ErrorException $e) {
            echo $e->__toString();
            $erro = array("erro" => $e->getMessage());
            return json_encode($erro);
        }
    }
537312
public function getContext()
    {
        if (!isset($this->context)) {
            $this->context = new RequestContext();
            $this->context->fromRequest($this->getRequest());
        }

        return $this->context;
    }
822027
private function _setRequestAndResponse()
    {
        if (!is_object($this->_request)) {
            $this->_request = \Mmi\App\FrontController::getInstance()->getRequest();
        }
        if (!is_object($this->_response)) {
            $this->_response = \Mmi\App\FrontController::getInstance()->getResponse();
        }
        return $this;
    }
413084
public function setResponse($response)
    {
        if (is_string($response) && class_exists($response)) {
            $response = new $response();
            if (!$response instanceof Zend_Amf_Response) {
                require_once 'Zend/Amf/Server/Exception.php';
                throw new Zend_Amf_Server_Exception('Invalid response class');
            }
        } elseif (!$response instanceof Zend_Amf_Response) {
            require_once 'Zend/Amf/Server/Exception.php';
            throw new Zend_Amf_Server_Exception('Invalid response object');
        }
        $this->_response = $response;
        return $this;
    }
1250519
public final static function fromPhpContext(PhpContext $phpContext)
    {
        if ($phpContext->isCliInvocation()) {
            $request = new CliRequest();
        } else {
            $contentType = (isset($_SERVER["CONTENT_TYPE"])) ? strtolower($_SERVER["CONTENT_TYPE"]) : "";

            // Special check for multipart, because the header could be multipart/form-data
            // followed by boundary
            $multipartType = "multipart/form-data";
            if (strpos($contentType, $multipartType) === 0) {
                $contentType = $multipartType;
            }

            // Firefox puts a charset on the end of the content type line
            $parts = explode(";", $contentType);
            $contentType = $parts[0];

            switch ($contentType) {
                case "application/octet-stream":
                case "image/jpeg":
                case "image/jpg":
                case "image/gif":
                case "image/png":
                    $request = new BinaryRequest();
                    break;
                case "application/json":
                    $request = new JsonRequest();
                    break;
                case "text/xml":
                case "application/xml":
                    $request = new XmlRequest();
                    break;
                case "multipart/form-data":
                    $request = new MultiPartFormDataRequest();
                    break;
                default:
                    $request = new WebRequest();
                    break;
            }
        }

        $request->phpContext = $phpContext;

        return $request;
    }
604461
private void fillResponseContext(UnitResponse.Context responseContext) {
        IdManager.makeSureMsgId(responseContext);
        responseContext.setNodeStatus(getSimpleStatus());
        responseContext.setMessageType(MessageType.response);
    }
67102
public function context($context = null)
    {
        if (is_null($context) || empty($context) || $context == "this") {
            $context = null;
        } else {
            $this->__contextAwareContext = $context;
        }
        return $this;
    }
907508
public static function fromResponse(ResponseInterface $response) : SetCookies
    {
        return new static(array_map(function (string $setCookieString) : SetCookie {
            return SetCookie::fromSetCookieString($setCookieString);
        }, $response->getHeader(static::SET_COOKIE_HEADER)));
    }
202874
protected function process(RequestInterface $request, string $responseClassName = null): ?ResponseInterface
    {
        $context = SerializationContext::create();

        $request = $this->serializer->serialize($request, $this->serializerFormat, $context);

        $response = $this->httpClient->post('', ['body' => $request]);

        if (!$responseClassName) {
            return null;
        }

        return $this->serializer->deserialize($response->getBody(), $responseClassName, $this->deserializerFormat);
    }
187086
private function buildSettings(ServerRequestInterface $request, ResponseInterface $response): CorsSettings
    {
        $settings = new CorsSettings;

        $origin = array_fill_keys((array) $this->options["origin"], true);
        $settings->setRequestAllowedOrigins($origin);

        if (is_callable($this->options["methods"])) {
            $methods = (array) $this->options["methods"]($request, $response);
        } else {
            $methods = $this->options["methods"];
        }
        $methods = array_fill_keys($methods, true);
        $settings->setRequestAllowedMethods($methods);

        $headers = array_fill_keys($this->options["headers.allow"], true);
        $headers = array_change_key_case($headers, CASE_LOWER);
        $settings->setRequestAllowedHeaders($headers);

        $headers = array_fill_keys($this->options["headers.expose"], true);
        $settings->setResponseExposedHeaders($headers);

        $settings->setRequestCredentialsSupported($this->options["credentials"]);

        if (is_string($this->options["origin.server"])) {
            $settings->setServerOrigin($this->options["origin.server"]);
        }

        $settings->setPreFlightCacheMaxAge($this->options["cache"]);

        return $settings;
    }
29575
public function setCurlOptions(array $curlOptions = []): RequestContext
    {
        $this->curlOptions = [];

        foreach ($curlOptions as $name => $value) {
            $this->setCurlOption($name, $value);
        }

        return $this;
    }
1197861
protected function setUriHeader(Request $request, Response $response)
    {
        $response->headers->set('X-PJAX-URL', $request->getUrl());

        return $this;
    }
129250
private function processTranslateResponse(ResponseContextAbstract $context): TranslateResponse
    {
        $responseArray = $context->getArray();

        $response = new TranslateResponse();

        $response->setTranslations((array)$responseArray['text']);

        if (isset($responseArray['lang'])) {
            list($fromLanguage, $toLanguage) = explode("-", $responseArray['lang']);

            if ($fromLanguage !== self::LANGUAGE_UNDETECTED) {
                $response->setLanguageFrom($fromLanguage);
            }

            $response->setLanguageTo($toLanguage);
        }

        return $response;
    }
1159156
public function setResponseType($responseType)
    {
        static $types = array(
            self::TYPE_PRIMITIVE => true,
            self::TYPE_CLASS => true,
            self::TYPE_MODEL => true,
            self::TYPE_DOCUMENTATION => true
        );
        if (!isset($types[$responseType])) {
            throw new InvalidArgumentException('responseType must be one of ' . implode(', ', array_keys($types)));
        }

        $this->responseType = $responseType;

        return $this;
    }
283104
private function prepareApiResponse(
        ResponseContextAbstract $responseContext,
        string $apiClassMethod
    ): ApiResponseInterface {
        $prepareApiResponse = sprintf("prepare%sResponse", ucfirst($apiClassMethod));

        $this->assertMethodExists($prepareApiResponse);

        $apiResponse = $this->{$prepareApiResponse}($responseContext);

        return $apiResponse;
    }
775062
protected function processApiResponseContextErrors(ResponseContextAbstract $responseContext): void
    {
        $responseArray = $responseContext->getArray();

        $this->filterYandexSpecificErrors($responseArray);

        parent::processApiResponseContextErrors($responseContext);

        if (empty($responseArray['text'])) {
            throw new InvalidResponseContent(sprintf('There is no required field "%s" in response', 'text'));
        }
    }