Create Illuminate Request.

@param array $get
@param array $post
@param array $cookie
@param array $files
@param array $server
@param string $content

@return void
342141
protected function createIlluminateRequest($get, $post, $cookie, $files, $server, $content = null)
    {
        IlluminateRequest::enableHttpMethodParameterOverride();

        /*
        |--------------------------------------------------------------------------
        | Copy from \Symfony\Component\HttpFoundation\Request::createFromGlobals().
        |--------------------------------------------------------------------------
        |
        | With the php's bug #66606, the php's built-in web server
        | stores the Content-Type and Content-Length header values in
        | HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields.
        |
        */

        if ('cli-server' === PHP_SAPI) {
            if (array_key_exists('HTTP_CONTENT_LENGTH', $server)) {
                $server['CONTENT_LENGTH'] = $server['HTTP_CONTENT_LENGTH'];
            }
            if (array_key_exists('HTTP_CONTENT_TYPE', $server)) {
                $server['CONTENT_TYPE'] = $server['HTTP_CONTENT_TYPE'];
            }
        }

        $request = new SymfonyRequest($get, $post, [], $cookie, $files, $server, $content);

        if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
            && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])
        ) {
            parse_str($request->getContent(), $data);
            $request->request = new ParameterBag($data);
        }

        $this->illuminateRequest = IlluminateRequest::createFromBase($request);
    }
1229636
public function toIlluminateRequest(array $rawServer = [], array $rawEnv = [])
    {
        $__GET = isset($this->swooleRequest->get) ? $this->swooleRequest->get : [];
        $__POST = isset($this->swooleRequest->post) ? $this->swooleRequest->post : [];
        $__COOKIE = isset($this->swooleRequest->cookie) ? $this->swooleRequest->cookie : [];
        $server = isset($this->swooleRequest->server) ? $this->swooleRequest->server : [];
        $headers = isset($this->swooleRequest->header) ? $this->swooleRequest->header : [];
        $__FILES = isset($this->swooleRequest->files) ? $this->swooleRequest->files : [];
        $_REQUEST = [];
        $_SESSION = [];

        static $headerServerMapping = [
            'x-real-ip'       => 'REMOTE_ADDR',
            'x-real-port'     => 'REMOTE_PORT',
            'server-protocol' => 'SERVER_PROTOCOL',
            'server-name'     => 'SERVER_NAME',
            'server-addr'     => 'SERVER_ADDR',
            'server-port'     => 'SERVER_PORT',
            'scheme'          => 'REQUEST_SCHEME',
        ];

        $_ENV = $rawEnv;
        $__SERVER = $rawServer;
        foreach ($headers as $key => $value) {
            // Fix client && server's info
            if (isset($headerServerMapping[$key])) {
                $server[$headerServerMapping[$key]] = $value;
            } else {
                $key = str_replace('-', '_', $key);
                $server['http_' . $key] = $value;
            }
        }
        $server = array_change_key_case($server, CASE_UPPER);
        $__SERVER = array_merge($__SERVER, $server);
        if (isset($__SERVER['REQUEST_SCHEME']) && $__SERVER['REQUEST_SCHEME'] === 'https') {
            $__SERVER['HTTPS'] = 'on';
        }

        // Fix REQUEST_URI with QUERY_STRING
        if (strpos($__SERVER['REQUEST_URI'], '?') === false
            && isset($__SERVER['QUERY_STRING'])
            && strlen($__SERVER['QUERY_STRING']) > 0
        ) {
            $__SERVER['REQUEST_URI'] .= '?' . $__SERVER['QUERY_STRING'];
        }

        // Fix argv & argc
        if (!isset($__SERVER['argv'])) {
            $__SERVER['argv'] = isset($GLOBALS['argv']) ? $GLOBALS['argv'] : [];
            $__SERVER['argc'] = isset($GLOBALS['argc']) ? $GLOBALS['argc'] : 0;
        }

        // Initialize laravel request
        IlluminateRequest::enableHttpMethodParameterOverride();
        $request = IlluminateRequest::createFromBase(new \Symfony\Component\HttpFoundation\Request($__GET, $__POST, [], $__COOKIE, $__FILES, $__SERVER, $this->swooleRequest->rawContent()));

        if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
            && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])
        ) {
            parse_str($request->getContent(), $data);
            $request->request = new ParameterBag($data);
        }

        return $request;
    }
1094871
public function post($uri, $content, $requestHeaders = array()) {
        try {
            return $this->executePost($uri, $content, $requestHeaders);
        } catch (Unauthenticated $e) {
            $this->auth_token->reset();
            return $this->executePost($uri, $content, $requestHeaders);
        }
    }
1159864
public function post($command, $params = null, $postcontenttype = 'application/json')
    {
        $url = $command;

        $headers = array('Content-Type' => $postcontenttype);

        $content = $params;
        if ($postcontenttype == 'application/json') {
            $content = json_encode($params);
        }

        try {
            $response = $this->client->post($url, ['headers' => $headers, 'body' => $content]);
        } catch (\Exception $e) {
            return null;
        }
        $this->checkError($response, $url);

        return $response->getBody();
    }
28636
public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
    {
        parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
        $this->json = new ParameterBag(Json::decode($this->getContent()) ?: array());
    }
1072601
protected function get($endpoint, $get = array()) {
		if ($get !== []) {
			$endpoint .= '?' . http_build_query($get);
		}

		$uri = new \TYPO3\Flow\Http\Uri($endpoint);
		$request = \TYPO3\Flow\Http\Request::create($uri, 'GET');
		$request->setContent('');
		$request = $this->authentication->authorizeRequest($request);
		$response = $this->requestEngine->sendRequest($request);

		return $response;
	}
488401
public function callSecure($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
    {
        $uri = $this->app['url']->secure(ltrim($uri, '/'));

        return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content);
    }
1092020
function getCookiesForRequest($cookies, $secure=false) {
		$cookie_str = '';
		if ((! is_null($cookies)) && (is_array($cookies))) {
			foreach ($cookies as $cookie) {
				if (! is_array($cookie)) {
					continue;
				}
	    		$this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
				if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
					if (strtotime($cookie['expires']) <= time()) {
						$this->debug('cookie has expired');
						continue;
					}
				}
				if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
					$domain = preg_quote($cookie['domain']);
					if (! preg_match("'.*$domain$'i", $this->host)) {
						$this->debug('cookie has different domain');
						continue;
					}
				}
				if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
					$path = preg_quote($cookie['path']);
					if (! preg_match("'^$path.*'i", $this->path)) {
						$this->debug('cookie is for a different path');
						continue;
					}
				}
				if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
					$this->debug('cookie is secure, transport is not');
					continue;
				}
				$cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
	    		$this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
			}
		}
		return $cookie_str;
  }
441903
public function createResource(
        $uri = "",
        $content = null,
        $headers = []
    ) {
        $options = ['http_errors' => false];

        // Set content.
        $options['body'] = $content;

        // Set headers.
        $options['headers'] = $headers;

        return $this->client->request(
            'POST',
            $uri,
            $options
        );
    }
1121321
function post($path = null, $postBody = null, $headers = null, $curlOpts = null) {
        $payload = $this -> encodePostBody($postBody);
        $this -> log -> debug("\n\n ====== Dump the payload before Http POST send! ====== \n\n$payload\n\n====== End Dump! ======\n");
        return $this -> request($path, self::HTTP_POST, $payload, $headers, $curlOpts);
    }
26063
public function request($function, array $params = array(), $cache = null)
    {
        $request = $this->startRequest($function, $params, $cache);

        return $this->fetchResponse($request);
    }
1211613
function request($uri,$method,$token=NULL) {
		$web=\Web::instance();
		$options=[
			'method'=>$method,
			'content'=>http_build_query($this->args),
			'header'=>['Accept: application/json']
		];
		if ($token)
			array_push($options['header'],'Authorization: Bearer '.$token);
		elseif ($method=='POST' && isset($this->args['client_id']))
			array_push($options['header'],'Authorization: Basic '.
				base64_encode(
					$this->args['client_id'].':'.
					$this->args['client_secret']
				)
			);
		$response=$web->request($uri,$options);
		if ($response['error'])
			user_error($response['error'],E_USER_ERROR);
		if (isset($response['body'])) {
			if (preg_grep('/^Content-Type:.*application\/json/i',
				$response['headers'])) {
				$token=json_decode($response['body'],TRUE);
				if (isset($token['error_description']))
					user_error($token['error_description'],E_USER_ERROR);
				if (isset($token['error']))
					user_error($token['error'],E_USER_ERROR);
				return $token;
			}
			else
				return $response['body'];
		}
		return FALSE;
	}
861231
public function request(string $resource, string $method, array $data = [], array $files = [])
	{
		if (!strpos($resource, '://')) {
			if (!strpos($resource, '.')) {
				$resource .= '.json';
			}
			$resource = self::API_URL . $resource;
		}

		foreach ($data as $key => $val) {
			if ($val === null) {
				unset($data[$key]);
			}
		}

		foreach ($files as $key => $file) {
			if (!is_file($file)) {
				throw new Exception("Cannot read the file $file. Check if file exists on disk and check its permissions.");
			}
			$data[$key] = new \CURLFile($file);
		}

		$headers = ['Expect:'];

		if ($method === 'JSONPOST') {
			$method = 'POST';
			$data = json_encode($data);
			$headers[] = 'Content-Type: application/json';

		} elseif ($method === 'GET' && $data) {
			$resource .= '?' . http_build_query($data, '', '&');
		}

		$request = OAuth\Request::from_consumer_and_token($this->consumer, $this->token, $method, $resource);
		$request->sign_request(new OAuth\SignatureMethod_HMAC_SHA1, $this->consumer, $this->token);
		$headers[] = $request->to_header();

		$options = [
			CURLOPT_URL => $resource,
			CURLOPT_HEADER => false,
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_HTTPHEADER => $headers,
		] + $this->httpOptions;
		if ($method === 'POST') {
			$options += [
				CURLOPT_POST => true,
				CURLOPT_POSTFIELDS => $data,
				CURLOPT_SAFE_UPLOAD => true,
			];
		}

		$curl = curl_init();
		curl_setopt_array($curl, $options);
		$result = curl_exec($curl);
		if (curl_errno($curl)) {
			throw new Exception('Server error: ' . curl_error($curl));
		}

		$payload = @json_decode($result, false, 128, JSON_BIGINT_AS_STRING); // intentionally @

		if ($payload === false) {
			throw new Exception('Invalid server response');
		}

		$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
		if ($code >= 400) {
			throw new Exception(isset($payload->errors[0]->message)
				? $payload->errors[0]->message
				: "Server error #$code with answer $result",
				$code
			);
		}

		return $payload;
	}
348771
public static function createFromGlobals(
        array $query = null,
        array $post = null,
        array $cookie = null,
        array $server = null,
        array $files = null,
        array $env = null,
        $content = null
    ) {
        $query = isset($query) ? $query : $_GET;
        $post = isset($post) ? $post : $_POST;
        $cookie = isset($cookie) ? $cookie : $_COOKIE;
        $server = isset($server) ? $server : $_SERVER;
        $files = isset($files) ? $files : $_FILES;
        $env = isset($env) ? $env : $_ENV;

        $server = self::setServerParam($server, [
            'CONTENT_LENGTH' => 'HTTP_CONTENT_LENGTH',
            'CONTENT_TYPE'   => 'HTTP_CONTENT_TYPE',
        ]);

        return new static($query, $post, $cookie, $server, $files, $env, $content);
    }
923002
public function buildRequest( array $getData, array $postData, array $uploadedFiles )
	{
		if ( $this->requestInfo->getMethod() == Http::METHOD_POST )
		{
			$mergedPostData = $this->getMergedData( $postData );
			$postRequest    = new PostRequest( $this->requestInfo, $mergedPostData, $uploadedFiles );

			return $postRequest;
		}
		elseif ( in_array( $this->requestInfo->getMethod(), [ Http::METHOD_GET, Http::METHOD_HEAD ] ) )
		{
			$mergedGetData = $this->getMergedData( $getData );

			$getRequest = new GetRequest( $this->requestInfo, $mergedGetData );

			return $getRequest;
		}
		else
		{
			throw new InvalidRequestMethod( $this->requestInfo->getMethod() );
		}
	}
827371
function get($resource, $query = array(), $headers = array()) {
        $url = $this->build_url($resource, $query);
        $key = $this->buildCacheKey('get', $resource, $url, $headers, $query);
        if (($this->cacher) && ($this->cacher->has($key))) return $this->cacher->get($key);
        $result = $this->client->get($url, [
            'headers' => array_merge([
                'Authorization' => $this->getBearer()
            ], $headers)
        ])->json();
        if ($this->cacher) $this->cacher->put($key, $result);
        return $result;
    }
851236
public static function create($type, $uri, $method = 'GET', $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
    {
        self::configureFactory($type);

        return \call_user_func_array([self::getClass($type), 'create'], [$uri, $method, $parameters, $cookies, $files, $server, $content]);
    }