Casts the request array into new Request object.

@param array $request - The request object
165582
public function cast($request)
    {
        if (is_array($request) || is_object($request)) {
            foreach ($request as $key => $value) {
                if (is_array($value)) {
                    $this->cast($value);
                } else {
                    $this->$key = $value;
                }
            }
        }
    }
503662
public function run($request)
    {
        $name = get_class($this);
        $verbose = $request->getVar('verbose');

        // Set new logger
        $logger = $this
            ->getLoggerFactory()
            ->getOutputLogger($name, $verbose);
        $this->setLogger($logger);
    }
1160822
public static function fromRingRequest(array $request)
    {
        $options = [];
        if (isset($request['version'])) {
            $options['protocol_version'] = $request['version'];
        }

        if (!isset($request['http_method'])) {
            throw new \InvalidArgumentException('No http_method');
        }

        return new Request(
            $request['http_method'],
            Core::url($request),
            isset($request['headers']) ? $request['headers'] : [],
            isset($request['body']) ? Stream::factory($request['body']) : null,
            $options
        );
    }
715578
public function setRequest(BaseRequest $request)
    {
        foreach ($request as $prop => $value) {
            $this->$prop = $value;
        }
    }
204472
public function doRequest($request)
    {
        $inputStream = fopen('php://memory', 'r+');
        $content = $request->getContent();
        if ($content !== null) {
            fwrite($inputStream, $content);
            rewind($inputStream);
        }

        $queryParams = [];
        $postParams = [];
        $queryString = parse_url($request->getUri(), PHP_URL_QUERY);
        if ($queryString != '') {
            parse_str($queryString, $queryParams);
        }
        if ($request->getMethod() !== 'GET') {
            $postParams = $request->getParameters();
        }

        $serverParams = $request->getServer();
        if (!isset($serverParams['SCRIPT_NAME'])) {
            //required by WhoopsErrorHandler
            $serverParams['SCRIPT_NAME'] = 'Codeception';
        }
        
        $cookies = $request->getCookies();
        $headers = $this->extractHeaders($request);

        //set cookie header because dflydev/fig-cookies reads cookies from header
        if (!empty($cookies)) {
            $headers['cookie'] = implode(';', array_map(function ($key, $value) {
                return "$key=$value";
            }, array_keys($cookies), $cookies));
        }

        $zendRequest = new ServerRequest(
            $serverParams,
            $this->convertFiles($request->getFiles()),
            $request->getUri(),
            $request->getMethod(),
            $inputStream,
            $headers,
            $cookies,
            $queryParams,
            $postParams
        );

        $this->request = $zendRequest;

        $cwd = getcwd();
        chdir(codecept_root_dir());

        if ($this->config['recreateApplicationBetweenRequests'] === true || $this->application === null) {
            $application = $this->initApplication();
        } else {
            $application = $this->application;
        }

        if (method_exists($application, 'handle')) {
            //Zend Expressive v3
            $response = $application->handle($zendRequest);
        } else {
            //Older versions
            $application->run($zendRequest);
            $response = $this->responseCollector->getResponse();
            $this->responseCollector->clearResponse();
        }

        chdir($cwd);

        return new Response(
            (string)$response->getBody(),
            $response->getStatusCode(),
            $response->getHeaders()
        );
    }
1143001
function send( $request )
    {
        $this->RequestPayload = '';
        $this->ResponsePayload = '';

        /// @todo add a check that request is a soap / phpsoap one, or it will have no namespace method...
        // nb: php soap code wants an integer as SoapVersion, eg. "2" will not work
        $options = array( 'exceptions' => true, 'soap_version' => (int)$this->SoapVersion );
        if ( $this->CacheWSDL >= 0 )
        {
            $options['cache_wsdl'] = $this->CacheWSDL;
        }

        /*
        if ( $this->Login != '' )
        {
            $options['login'] = $this->Login;
            $options['password'] = $this->Password;
        }
        if ( $this->Proxy != '' )
        {
            $options['proxy_host'] = $this->Proxy;
            $options['proxy_port'] = $this->ProxyPort;
            if ( $this->ProxyLogin != '' )
            {
                $options['proxy_login'] = $this->ProxyLogin;
                $options['proxy_password'] = $this->ProxyPassword;
            }
        }*/
        if ( $this->Wsdl == null )
        {
            // non-wsdl mode
            $options['location'] = $this->Protocol . "://" . $this->Server . ":" . $this->Port . $this->Path;
            /// @todo test if request is not a ggsoaprequest / ggphpsoaprequest
            ///       and has thus no ->ns() method
            $options['uri'] = $request->ns();
        }
        else
        {
            if ( preg_match( '#^https?://#', $this->Wsdl ) && $this->Timeout != 0 )
            {
                // patch around buggy soapclient behaviour: force socket timeout on getting wsdl call
                $deftimeout = ini_get( 'default_socket_timeout' );
                if ( $deftimeout !=  $this->Timeout )
                {
                    ini_set( 'default_socket_timeout', $this->Timeout );
                }
                else
                {
                    unset( $deftimeout );
                }
            }

        }
        try
        {
            $response = new $this->ResponseClass();

            $client = new ggPhpSOAPClientTransport( $this->Wsdl, $options, $this, $request );
            if ( isset( $deftimeout ) )
            {
                ini_set( 'default_socket_timeout', $deftimeout );
            }

            // a hackish way to emulate listMethods calls
            $rname = $request->name();
            if ( $rname == 'system.listMethods' || $rname == 'system.methodSignature' )
            {

                $results = $client->__getFunctions();
                if ( !is_array( $results ) )
                {
                    throw new Exception( 'Could not parse wsdl into array of functions' );
                }
                else
                {
                    $mname = '';
                    if ( $rname == 'system.methodSignature' )
                    {
                        $mname = $request->parameters();
                        $mname = $mname[0];
                    }
                    $results = ggWSDLParser::transformGetFunctionsResults( $results, $rname, $mname );
                }
            }
            else
            {
                $results = $client->__soapCall( $rname, $request->parameters(), array(), array(), $output_headers );
            }

            // phpSoapResponse responses do not parse anything anyway - no need to call this
            //$rawResponse = $client->__getLastResponse();
            //$response->decodeStream( $request, $rawResponse );
            if ( is_soap_fault( $results ) )
            {
                $response->setValue( new ggWebservicesFault( $results->faultcode, $results->faultstring ) );
            }
            else
            {
                if ( $this->returnArrays )
                {
                    $results = $this->toArray( $results );
                }
                $response->setValue( $results );
            }
            return $response;
        }
        catch( exception $e )
        {
            if ( isset( $deftimeout ) )
            {
                ini_set( 'default_socket_timeout', $deftimeout );
            }
            if ( $this->errorNumber() )
            {
                $response->setValue( new ggWebservicesFault( $this->errorNumber(), $this->errorString() ) );
            }
            else if ( $e instanceof SoapFault )
            {
                $response->setValue( new ggWebservicesFault( $e->faultcode, $e->faultstring ) );
            }
            else
            {
                $response->setValue( new ggWebservicesFault( $e->getCode(), $e->getMessage() ) );
            }
            return $response;
        }

    }
1269822
public function initializeRequest($request = null)
	{
		if (empty($request)) {
			$this->request = Request::createFromGlobals();
		} else {
			$this->request = $request;
		}

		// Shortcuts to the request object for cleaner syntax.
		$this->input = new Input($this->request);
	}
978359
public function proxyAction(Request $request)
    {
        $api = $this->decideApiAndEndpoint($request->getUri());
        $this->registerProxySources($api['apiName']);
        $this->apiLoader->addOptions($api);

        $url = new Uri($this->apiLoader->getEndpoint($api['endpoint'], true));

        if ($url->getScheme() === null) {
            $url = $url->withScheme($request->getScheme());
        }

        $response = null;
        try {
            $newRequest = Request::create(
                (string) $url,
                $request->getMethod(),
                [],
                [],
                [],
                [],
                $request->getContent(false)
            );
            $newRequest->headers->add($request->headers->all());
            $newRequest->query->add($request->query->all());

            $newRequest = $this->transformationHandler->transformRequest(
                $api['apiName'],
                $api['endpoint'],
                $request,
                $newRequest
            );

            $psrRequest = $this->psrHttpFactory->createRequest($newRequest);

            $psrRequestUri = $psrRequest->getUri();
            $psrRequestUriPort = $url->getPort();
            if (is_numeric($psrRequestUriPort) || is_null($psrRequestUriPort)) {
                $psrRequestUri = $psrRequestUri->withPort($psrRequestUriPort);
            }

            $psrRequest = $psrRequest->withUri($psrRequestUri);

            $psrResponse = $this->proxy->forward($psrRequest)->to($this->getHostWithScheme($url));
            $response = $this->httpFoundationFactory->createResponse($psrResponse);
            $this->cleanResponseHeaders($response->headers);
            $this->transformationHandler->transformResponse(
                $api['apiName'],
                $api['endpoint'],
                $response,
                clone $response
            );
        } catch (ClientException $e) {
            $response = (new HttpFoundationFactory())->createResponse($e->getResponse());
        } catch (ServerException $serverException) {
            $response = (new HttpFoundationFactory())->createResponse($serverException->getResponse());
        } catch (TransformationException $e) {
            $message = json_encode(
                ['code' => 404, 'message' => 'HTTP 404 Not found']
            );

            throw new NotFoundHttpException($message, $e);
        } catch (RequestException $e) {
            $message = json_encode(
                ['code' => 404, 'message' => 'HTTP 404 Not found']
            );

            throw new NotFoundHttpException($message, $e);
        }

        return $response;
    }
883017
public function setRequest(array $request)
    {
        parent::setRequest($request);

        if (isset($this->_request->term)) {
            $value = $this->getService('anahita:filter.term')->sanitize($this->_request->term);
            $this->_request->term = $value;
            $this->term = $value;
        }

        if (isset($this->_request->search_range)) {
            $value = (int) $this->_request->search_range;
            $this->_request->search_range = $value;
            $this->search_range = $value;
        }

        if ($this->_request->search_comments == 1 || $this->_request->search_comments == 'true') {
           $value = true;
        } else {
           $value = false;
        }

        $this->_request->search_comments = $value;
        $this->search_comments = $value;

        return $this;
    }
1140743
public function _invokeAsArray(array $request)
    {
        $factory = $this->factory;

        // Ensure headers are by reference. They're updated elsewhere.
        $result = $factory($request, curl_init());
        $h = $result[0];
        $hd = &$result[1];
        $body = $result[2];
        Core::doSleep($request);

        try {
            // override the default body stream with the request response
            $safecurl = new SafeCurl($h);
            $body = $safecurl->execute(Core::url($request));
        } catch (Exception $e) {
            // URL wasn't safe, return empty content
            $body = '';
            $safeCurlError = $e->getMessage();
        }

        $response = ['transfer_stats' => curl_getinfo($h)];
        $response['curl']['error'] = curl_error($h);
        $response['curl']['errno'] = curl_errno($h);
        $response['transfer_stats'] = array_merge($response['transfer_stats'], $response['curl']);
        curl_close($h);

        // override default error message in case of SafeCurl error
        if (isset($safeCurlError)) {
            $response['err_message'] = $safeCurlError;
        }

        return CurlFactory::createResponse([$this, '_invokeAsArray'], $request, $response, $hd, Stream::factory($body));
    }
1372099
public static function proxy ($request) {

		if (!$request instanceof Request) {
			$url = $request;

			$request = new Request ();
			$request->setUrl ($url);
			$request->setMethod (Request::METHOD_GET);
		}

		return Client::getInstance ()->process ($request);
	}
1126326
public function toArray($request)
    {
        return [
            'id'         => (int) $this->id,
            'email'      => $this->email,
            'name'       => $this->name,
            'first_name' => $this->first_name,
            'last_name'  => $this->last_name,
            'roles'      => Role::collection($this->whenLoaded('roles')),
        ];
    }
776094
protected function bindParamListIfProvided(JsonRpcRequest $request, array $item) : void
    {
        if (isset($item[self::KEY_PARAM_LIST])) {
            $this->validateArray($item[self::KEY_PARAM_LIST], 'Parameter list must be an array');
            $request->setParamList($item[self::KEY_PARAM_LIST]);
        }
    }
229660
public function makeRequest($request)
    {
        $optionsSet = curl_setopt_array($this->ch, [
            CURLOPT_URL => $this->url,
            CURLOPT_HEADER => false,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_CONNECTTIMEOUT => $this->timeout,
            CURLOPT_USERAGENT => 'JSON-RPC Random.org PHP Client',
            CURLOPT_HTTPHEADER => $this->headers,
            CURLOPT_FOLLOWLOCATION => false,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_SSL_VERIFYPEER => $this->verifyPeer,
            CURLOPT_POSTFIELDS => json_encode($request)
        ]);

        if (!$optionsSet) {
            throw new \Exception('Cannot set curl options');
        }

        $responseBody = curl_exec($this->ch);
        $responseCode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);

        if (curl_errno($this->ch)) {
            throw new \RuntimeException(curl_error($this->ch));
        }

        if ($responseCode === 401 || $responseCode === 403) {
            throw new \RuntimeException('Access denied');
        }

        $response = json_decode($responseBody, true);

        if ($this->debug) {
            echo('==> Request: '.PHP_EOL.json_encode($request, JSON_PRETTY_PRINT));
            echo('==> Response: '.PHP_EOL.json_encode($response, JSON_PRETTY_PRINT));
        }

        return $response;
    }
1322304
public function bindRequest(Request $request)
    {
        $this->request = $request;

        foreach ($this->request->postArray() as $key => $value) {
            if (isset($this->fieldSet[$key])) {
                $this->fieldSet[$key]->setValue($value);
            }
        }
    }
223650
protected function doRequest($request)
    {
        if (!$this->firstRequest) {
            $this->initialize($request);
        }
        $this->firstRequest = false;

        $this->applyBindings();
        $this->applyContextualBindings();
        $this->applyInstances();
        $this->applyApplicationHandlers();

        $request = Request::createFromBase($request);
        $response = $this->kernel->handle($request);

        $method = new \ReflectionMethod(get_class($this->app), 'callTerminableMiddleware');
        $method->setAccessible(true);
        $method->invoke($this->app, $response);

        return $response;
    }
1101915
public function prepareRequest(Request $request)
	{
		$this->ch = curl_init();
		curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($this->ch, CURLOPT_HEADER, true);
		if ($auth = $request->getUserAndPass()) {
			curl_setopt($this->ch, CURLOPT_USERPWD, $auth);
		}
		curl_setopt($this->ch, CURLOPT_URL, $request->getUrl());

		$options = $request->getOptions();
		if (!empty($options)) {
			curl_setopt_array($this->ch, $options);
		}

		$method = $request->getMethod();
		curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));

		curl_setopt($this->ch, CURLOPT_HTTPHEADER, $request->formatHeaders());

		if ($request->hasData()) {
			curl_setopt($this->ch, CURLOPT_POSTFIELDS, $request->encodeData());
		}

		if ($method === 'head') {
			curl_setopt($this->ch, CURLOPT_NOBODY, true);
		}
	}