Logic largely refactored from the ZF2 Zend\Http\PhpEnvironment\Request class.
 public function testNormalizeServerReturnsArrayUnalteredIfApacheHeadersDoNotContainAuthorization()
 {
     $r = new ReflectionProperty('Phly\\Http\\ServerRequestFactory', 'apacheRequestHeaders');
     $r->setAccessible(true);
     $r->setValue(function () {
         return [];
     });
     $expected = ['FOO_BAR' => 'BAZ'];
     $server = ServerRequestFactory::normalizeServer($expected);
     $this->assertEquals($expected, $server);
 }
예제 #2
0
 /**
  * Create a Server instance
  *
  * Creates a server instance from the callback and the following
  * PHP environmental values:
  *
  * - server; typically this will be the $_SERVER superglobal
  * - query; typically this will be the $_GET superglobal
  * - body; typically this will be the $_POST superglobal
  * - cookies; typically this will be the $_COOKIE superglobal
  * - files; typically this will be the $_FILES superglobal
  *
  * @param callable $callback
  * @param array $server
  * @param array $query
  * @param array $body
  * @param array $cookies
  * @param array $files
  * @return self
  */
 public static function createServer(callable $callback, array $server, array $query, array $body, array $cookies, array $files)
 {
     $request = ServerRequestFactory::fromGlobals($server, $query, $body, $cookies, $files);
     $response = new Response();
     return new self($callback, $request, $response);
 }
예제 #3
0
파일: Http.php 프로젝트: somos/framework
 public function __invoke()
 {
     return [\Phly\Http\ServerRequest::class => \DI\factory(function () {
         return \Phly\Http\ServerRequestFactory::fromGlobals();
     })];
 }