Converts the request to a PSR-7 RequestInterface

@return \Psr\Http\Message\RequestInterface
515627
function createHttpRequest()
    {
        $headers = [
            'User-Agent' => $this->getContext()->getUserAgent(),
            'Content-Type' => 'application/x-www-form-urlencoded'
        ];

        $body = $this->buildQuery($this->getRequestParameters());

        return $this->getContext()->getMessageFactory()->createRequest(
            'POST',
            $this->getEndpoint(),
            $headers,
            $body
        );

        $httpRequest = new Request(
            'POST',
            $this->getEndpoint(),
            $headers,
            $body
        );

        return $httpRequest;
    }
91397
protected function getPsrRequestViaBearerToken($request)
    {
        // First, we will convert the Symfony request to a PSR-7 implementation which will
        // be compatible with the base OAuth2 library. The Symfony bridge can perform a
        // conversion for us to a Zend Diactoros implementation of the PSR-7 request.
        $psr = (new DiactorosFactory)->createRequest($request);

        try {
            return $this->server->validateAuthenticatedRequest($psr);
        } catch (OAuthServerException $e) {
            $request->headers->set('Authorization', '', true);

            Container::getInstance()->make(
                ExceptionHandler::class
            )->report($e);
        }
    }
1015579
private function transformRequest(\swoole_http_request $swooleRequest)
    {
        return $this->psr7Factory->createRequest(
            $this->transformUri($swooleRequest),
            $this->transformRequestMethod($swooleRequest),
            $this->transformBody($swooleRequest),
            $this->transformHeader($swooleRequest)
        )
            ->withProtocolVersion($this->transformProtocolVersion($swooleRequest))
        ;
    }
58254
public function getResponse(): ResponseInterface
    {
        if (is_null($this->response)) {
            if (method_exists($this, 'resolve')) {
                $this->setResponse($this->resolve(Response::class)->load());
            } else {
                $response = new Response();
                $this->setResponse($response->load());
            }
        }

        return $this->response;
    }
135294
public function send(\Psr\Http\Message\RequestInterface $request)
    {
        if($this->credentials instanceof Container) {
            if ($this->needsKeypairAuthentication($request)) {
                $request = $request->withHeader('Authorization', 'Bearer ' . $this->credentials->get(Keypair::class)->generateJwt());
            } else {
                $request = self::authRequest($request, $this->credentials->get(Basic::class));
            }
        } elseif($this->credentials instanceof Keypair){
            $request = $request->withHeader('Authorization', 'Bearer ' . $this->credentials->generateJwt());
        } elseif($this->credentials instanceof SignatureSecret){
            $request = self::signRequest($request, $this->credentials);
        } elseif($this->credentials instanceof Basic){
            $request = self::authRequest($request, $this->credentials);
        }

        //todo: add oauth support

        //allow any part of the URI to be replaced with a simple search
        if(isset($this->options['url'])){
            foreach($this->options['url'] as $search => $replace){
                $uri = (string) $request->getUri();

                $new = str_replace($search, $replace, $uri);
                if($uri !== $new){
                    $request = $request->withUri(new Uri($new));
                }
            }
        }

        // The user agent must be in the following format:
        // LIBRARY-NAME/LIBRARY-VERSION LANGUAGE-NAME/LANGUAGE-VERSION [APP-NAME/APP-VERSION]
        // See https://github.com/Nexmo/client-library-specification/blob/master/SPECIFICATION.md#reporting
        $userAgent = [];

        // Library name
        $userAgent[] = 'nexmo-php/'.self::VERSION;

        // Language name
        $userAgent[] = 'php/'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;

        // If we have an app set, add that to the UA
        if (isset($this->options['app'])) {
            $app = $this->options['app'];
            $userAgent[] = $app['name'].'/'.$app['version'];
        }

        // Set the header. Build by joining all the parts we have with a space
        $request = $request->withHeader('User-Agent', implode(" ", $userAgent));

        $response = $this->client->sendRequest($request);
        return $response;
    }
1167572
public function createServerRequest(): ServerRequestInterface
    {
        $server_request_creator = new ServerRequestCreator(
            app(ServerRequestFactoryInterface::class),
            app(UriFactoryInterface::class),
            app(UploadedFileFactoryInterface::class),
            app(StreamFactoryInterface::class)
        );

        // Until all the code is rewritten to use PSR-7 requests, we still need our hybrid request.
        if (class_exists(Request::class)) {
            return Request::createFromGlobals();
        }

        return $server_request_creator->fromGlobals();
    }
1323005
public static function fromEnvironment(): RequestInterface
    {
        $headers = [];
        foreach ($_SERVER as $name => $value) {
            if (strpos($name, 'HTTP_') === 0) {
                $name = substr($name, 5);
                $name = str_replace('_', ' ', $name);
                $name = strtolower($name);
                $name = ucwords($name);
                $name = str_replace(' ', '-', $name);

                $headers[$name] = $value;
            }
        }

        $input = file_get_contents('php://input') ?: '';
        if (empty($input) === false) {
            $body = json_decode(file_get_contents('php://input') ?: '');
            if (json_last_error() !== JSON_ERROR_NONE) {
                throw new InvalidRequestBody(json_last_error_msg());
            }
        }

        return (new static())
            ->withMethod($_SERVER['REQUEST_METHOD'])
            ->withBody($body ?? null)
            ->withHeaders($headers)
            ->withUri(Uri::fromEnvironment());
    }
343179
protected function requestProcessor()
    {
        $components = $this->builder->components();

        $processors     = $components->processors();
        $httpProcessors = $components->httpProcessors();

        return $processors->chain(array(
            $httpProcessors->parseBody(),
            $this->parseRouteProcessor(),
            $httpProcessors->buildRequest()
        ));
    }
615332
public function getRequest(): RequestInterface
    {
        if (is_null($this->request)) {
            if (method_exists($this, 'resolve')) {
                $this->setRequest($this->resolve(Request::class)->load());
            } else {
                $request = new Request();
                $this->setRequest($request->load());
            }
        }

        return $this->request;
    }
241347
public function toProtobufRequest()
    {
        $request = new \POGOProtos\Networking\Requests\Request();
        $request->setRequestType($this->getType());

        if (($message = $this->getMessage()) !== null) {
            $request->setRequestMessage($message->toStream());
        }

        return $request;
    }
344903
protected function getRequestUri()
    {

        if (!$this->requestUri) {
            $this->requestUri = rtrim($this->endpointUri, '/') . '/' . $this->version;
        }

        return $this->requestUri;

    }
353820
public function request()
    {
        $reqUrl = sprintf('%s?APIKEY=%s', self::END_POINT_URL, rawurlencode($this->apikey));
        $reqBody = json_encode($this->getParameter()->makeParameter());

        $curl = new Curl();
        $curl->setHeader('Content-Type', 'application/json; charset=UTF-8');
        $ret = $curl->post($reqUrl, $reqBody);
        if ($curl->error) {
            trigger_error('docomo dialogue: Error ' . $curl->errorCode . ': ' . $curl->errorMessage, E_USER_WARNING);
            return false;
        }
        return new Response($ret);
    }
681150
public function transducer(RequestInterface $request)
    {
        $response = null;
        if (count($this->middleware)) {
            $md = array_pop($this->middleware);
            $next = function (RequestInterface $request) {
                return $this->transducer($request);
            };

            if (is_callable($md)) {
                $response = $md($request, $next);
            } elseif (is_array($md)) {
                list($class, $action) = $md;
                $instance = is_object($class) ? $class : new $class();
                $response = $instance->$action($request, $next);
            }

            if ($response instanceof Generator) {
                $response = Poroutine::resolve($response);
            }
        }

        return $response ?? new Response();
    }
1196758
public function send(): ResponseInterface
    {
        $client = new HttpClient(['base_uri' => $this->url]);

        return $client->get(
            $this->getUrlPath(),
            [
                'query' => $this->getParams(),
            ]
        );
    }
125165
public function getRequest()
    {
        if (isset($_SERVER['REQUEST_METHOD'])) {
            return new PhpRequest(
                empty($_SESSION) ? [] : $_SESSION,
                empty($_COOKIE) ? [] : $_COOKIE,
                getallheaders(),
                $_SERVER,
                static::getInputParams($_SERVER, $_POST)
            );
        }

        return new NullRequest();
    }
851964
public function convert(ResponseInterface $psrResponse)
    {
        return new BrowserKitResponse(
            (string)$psrResponse->getBody(),
            $psrResponse->getStatusCode() ?: 200,
            $this->flattenHeaders($psrResponse->getHeaders())
        );
    }
1331295
public function getRequest()
    {
        if(!$this->_request instanceof DispatcherRequestInterface)
        {
            //Setup the request
            $this->_request->user = $this->getUser();

            $this->_request = $this->getObject('dispatcher.request', ObjectConfig::unbox($this->_request));

            if(!$this->_request instanceof DispatcherRequestInterface)
            {
                throw new \UnexpectedValueException(
                    'Request: '.get_class($this->_request).' does not implement DispatcherRequestInterface'
                );
            }
        }

        return $this->_request;
    }