当前位置: 首页>>代码示例>>PHP>>正文


PHP ServerRequestFactory::normalizeServer方法代码示例

本文整理汇总了PHP中Zend\Diactoros\ServerRequestFactory::normalizeServer方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerRequestFactory::normalizeServer方法的具体用法?PHP ServerRequestFactory::normalizeServer怎么用?PHP ServerRequestFactory::normalizeServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Diactoros\ServerRequestFactory的用法示例。


在下文中一共展示了ServerRequestFactory::normalizeServer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fromGlobals

 public static function fromGlobals(array $server = null, array $query = null, array $body = null, array $cookies = null, array $files = null)
 {
     $server = parent::normalizeServer($server);
     $files = parent::normalizeFiles($files);
     $headers = parent::marshalHeaders($server);
     return new ServerRequest($server, $files, parent::marshalUriFromServer($server, $headers), parent::get('REQUEST_METHOD', $server, 'GET'), 'php://input', $headers, $cookies, $query, $body, self::marshalProtocolVersion($server));
 }
开发者ID:mkorkmaz,项目名称:selami,代码行数:7,代码来源:ServerRequestFactory.php

示例2: testServerParams

 public function testServerParams()
 {
     $swooleRequest = $this->createSwooleRequest(array('request_method' => 'GET', 'request_uri' => '/', 'path_info' => '/', 'request_time' => 123456789, 'server_port' => 9100, 'remote_port' => 49648, 'remote_addr' => '127.0.0.1', 'server_protocol' => 'HTTP/1.1', 'server_software' => 'swoole-http-server'), array('authorization' => 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'host' => 'syrma.local', 'connection' => 'close', 'user-agent' => 'curl/7.35.0', 'accept' => '*/*'));
     $request = $this->createTransformer()->transform($swooleRequest);
     $expServerParams = new ServerRequest(ServerRequestFactory::normalizeServer(array('REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/', 'PATH_INFO' => '/', 'REQUEST_TIME' => 123456789, 'SERVER_PORT' => 9100, 'REMOTE_PORT' => 49648, 'REMOTE_ADDR' => '127.0.0.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SOFTWARE' => 'swoole-http-server', 'HTTP_AUTHORIZATION' => 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'HTTP_HOST' => 'syrma.local', 'HTTP_CONNECTION' => 'close', 'HTTP_USER-AGENT' => 'curl/7.35.0', 'HTTP_ACCEPT' => '*/*')));
     $this->assertInstanceOf(ServerRequest::class, $request);
     /* @var  ServerRequest $request */
     $this->assertSame($expServerParams->getServerParams(), $request->getServerParams());
 }
开发者ID:syrma-php,项目名称:web-container,代码行数:9,代码来源:SwooleMessageTransformerServerTest.php

示例3: testServerParams

 public function testServerParams()
 {
     $reactRequest = $this->createReactRequest('GET', '/', array(), '1.1', array('Host' => 'syrma.local', 'Connection' => 'close', 'User-Agent' => 'curl/7.35.0', 'Accept' => '*/*', 'Authorization' => 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='));
     $reactRequest->remoteAddress = '127.0.0.1';
     $request = $this->createTransformer()->transform($reactRequest);
     $expServerParams = new ServerRequest(ServerRequestFactory::normalizeServer(array('REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SOFTWARE' => 'reactphp-http', 'REMOTE_ADDR' => '127.0.0.1', 'HTTP_AUTHORIZATION' => 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'HTTP_HOST' => 'syrma.local', 'HTTP_CONNECTION' => 'close', 'HTTP_USER-AGENT' => 'curl/7.35.0', 'HTTP_ACCEPT' => '*/*')));
     $this->assertInstanceOf(ServerRequest::class, $request);
     /* @var  ServerRequest $request */
     $this->assertEquals($expServerParams->getServerParams(), $request->getServerParams());
 }
开发者ID:syrma-php,项目名称:web-container,代码行数:10,代码来源:ReactMessageTransformerServerTest.php

示例4: createRequest

 /**
  * Creates a PSR-7 compatible request
  *
  * @param \TYPO3\Flow\Http\Request $nativeRequest Flow request object
  * @param array $files List of uploaded files like in $_FILES
  * @param array $query List of uploaded files like in $_GET
  * @param array $post List of uploaded files like in $_POST
  * @param array $cookies List of uploaded files like in $_COOKIES
  * @param array $server List of uploaded files like in $_SERVER
  * @return \Psr\Http\Message\ServerRequestInterface PSR-7 request object
  */
 protected function createRequest(\TYPO3\Flow\Http\Request $nativeRequest, array $files, array $query, array $post, array $cookies, array $server)
 {
     $server = ServerRequestFactory::normalizeServer($server);
     $files = ServerRequestFactory::normalizeFiles($files);
     $headers = $nativeRequest->getHeaders()->getAll();
     $uri = (string) $nativeRequest->getUri();
     $method = $nativeRequest->getMethod();
     $body = new Stream('php://temp', 'wb+');
     $body->write($nativeRequest->getContent());
     return new ServerRequest($server, $files, $uri, $method, $body, $headers, $cookies, $query, $post);
 }
开发者ID:aimeos,项目名称:ai-flow,代码行数:22,代码来源:Flow.php

示例5: createRequest

 /**
  * Creates a PSR-7 compatible request
  *
  * @param \TYPO3\Flow\Http\Request $nativeRequest Flow request object
  * @param array $files List of uploaded files like in $_FILES
  * @param array $query List of uploaded files like in $_GET
  * @param array $post List of uploaded files like in $_POST
  * @param array $cookies List of uploaded files like in $_COOKIES
  * @param array $server List of uploaded files like in $_SERVER
  * @return \Psr\Http\Message\ServerRequestInterface PSR-7 request object
  */
 protected function createRequest(array $files, array $query, array $post, array $cookies, array $server)
 {
     if (!isset($server['HTTP_HOST'])) {
         $server['HTTP_HOST'] = 'localhost';
     }
     $files = ServerRequestFactory::normalizeFiles($files);
     $server = ServerRequestFactory::normalizeServer($server);
     $headers = ServerRequestFactory::marshalHeaders($server);
     $uri = ServerRequestFactory::marshalUriFromServer($server, $headers);
     $method = ServerRequestFactory::get('REQUEST_METHOD', $server, 'GET');
     return new ServerRequest($server, $files, $uri, $method, 'php://input', $headers, $cookies, $query, $post);
 }
开发者ID:aimeos,项目名称:ai-typo3,代码行数:23,代码来源:Typo3.php

示例6: createRequest

 /**
  * {@inheritdoc}
  */
 public function createRequest(Request $symfonyRequest)
 {
     $server = DiactorosRequestFactory::normalizeServer($symfonyRequest->server->all());
     $headers = $symfonyRequest->headers->all();
     $body = new DiactorosStream('php://temp', 'wb+');
     $body->write($symfonyRequest->getContent());
     $request = new ServerRequest($server, DiactorosRequestFactory::normalizeFiles($this->getFiles($symfonyRequest->files->all())), $symfonyRequest->getUri(), $symfonyRequest->getMethod(), $body, $headers);
     $request = $request->withCookieParams($symfonyRequest->cookies->all())->withQueryParams($symfonyRequest->query->all())->withParsedBody($symfonyRequest->request->all());
     foreach ($symfonyRequest->attributes->all() as $key => $value) {
         $request = $request->withAttribute($key, $value);
     }
     return $request;
 }
开发者ID:aimeos,项目名称:psr-http-message-bridge,代码行数:16,代码来源:DiactorosFactory.php

示例7: createRequest

 /**
  * Transforms a Symfony request into a PSR-7 request object
  *
  * @param \Illuminate\Http\Request $nativeRequest Laravel request object
  * @return \Psr\Http\Message\ServerRequestInterface PSR-7 request object
  */
 protected function createRequest(\Illuminate\Http\Request $nativeRequest)
 {
     $files = ServerRequestFactory::normalizeFiles($this->getFiles($nativeRequest->files->all()));
     $server = ServerRequestFactory::normalizeServer($nativeRequest->server->all());
     $headers = $nativeRequest->headers->all();
     $cookies = $nativeRequest->cookies->all();
     $post = $nativeRequest->request->all();
     $query = $nativeRequest->query->all();
     $method = $nativeRequest->getMethod();
     $uri = $nativeRequest->getUri();
     $body = new Stream('php://temp', 'wb+');
     $body->write($nativeRequest->getContent());
     $request = new ServerRequest($server, $files, $uri, $method, $body, $headers, $cookies, $query, $post);
     foreach ($nativeRequest->attributes->all() as $key => $value) {
         $request = $request->withAttribute($key, $value);
     }
     return $request;
 }
开发者ID:aimeos,项目名称:ai-laravel,代码行数:24,代码来源:Laravel5.php

示例8: __construct

 /**
  * Sapi constructor.
  *
  * @param EmitterInterface                $sapiEmitter
  * @param array|null                      $server
  * @param array|null                      $queryParams
  * @param array|object|null               $parsedBody
  * @param array|null                      $cookies
  * @param array|null                      $files
  * @param string|resource|StreamInterface $messageBody
  *
  * @SuppressWarnings(PHPMD.StaticAccess)
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function __construct(EmitterInterface $sapiEmitter, array $server = null, array $queryParams = null, array $parsedBody = null, array $cookies = null, array $files = null, $messageBody = 'php://input')
 {
     $this->sapiEmitter = $sapiEmitter;
     // returns value if not null or $fallback otherwise
     $get = function ($nullable, $fallback) {
         return $nullable !== null ? $nullable : $fallback;
     };
     // Code below based on ServerRequestFactory::fromGlobals
     $this->server = ServerRequestFactory::normalizeServer($get($server, $_SERVER));
     $this->files = ServerRequestFactory::normalizeFiles($get($files, $_FILES));
     $this->headers = ServerRequestFactory::marshalHeaders($this->server);
     $this->uri = ServerRequestFactory::marshalUriFromServer($this->server, $this->headers);
     $this->method = ServerRequestFactory::get('REQUEST_METHOD', $this->server, 'GET');
     $this->cookies = $get($cookies, $_COOKIE);
     $this->queryParams = $get($queryParams, $_GET);
     $this->parsedBody = $get($parsedBody, $_POST);
     $this->messageBody = $messageBody;
 }
开发者ID:limoncello-php,项目名称:core,代码行数:32,代码来源:Sapi.php

示例9: getServerRequest

 /**
  * {@inheritdoc}
  */
 public function getServerRequest()
 {
     $query = $this->getQuery();
     $post = $this->getPost();
     $cookies = $this->getCookies();
     $server = ServerRequestFactory::normalizeServer($this->params);
     $headers = ServerRequestFactory::marshalHeaders($server);
     $uri = ServerRequestFactory::marshalUriFromServer($server, $headers);
     $method = ServerRequestFactory::get('REQUEST_METHOD', $server, 'GET');
     $request = new ServerRequest($server, [], $uri, $method, $this->stdin, $headers);
     return $request->withCookieParams($cookies)->withQueryParams($query)->withParsedBody($post);
 }
开发者ID:sojimaxi,项目名称:FastCGIDaemon,代码行数:15,代码来源:Request.php


注:本文中的Zend\Diactoros\ServerRequestFactory::normalizeServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。