Exemplo n.º 1
0
 /**
  * @param \SplFileInfo $path
  * @param Request      $request
  * @param array        $env
  *
  * @return array
  */
 protected function createEnvVars(\SplFileInfo $path, Request $request, array $env = [])
 {
     $env = array_merge($env, ['REQUEST_URI' => $request->getUri() . ($request->getQueryString() ? '?' . $request->getQueryString() : ''), 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => $request->getServerPort(), 'QUERY_STRING' => $request->getQueryString(), 'SCRIPT_NAME' => $request->getPath(), 'SCRIPT_FILENAME' => $path->getRealPath(), 'REQUEST_METHOD' => $request->getMethod(), 'REDIRECT_STATUS' => 200, 'SERVER_SOFTWARE' => 'Coupe/PHP ' . PHP_VERSION . ' Development Server', 'REMOTE_ADDR' => $request->getRemoteAddr(), 'REMOTE_PORT' => $request->getRemotePort()]);
     if ($request->getPathInfo()) {
         $env['PATH_INFO'] = $request->getPathInfo();
     }
     if ($request->getHeader('Content-Length')) {
         $env['CONTENT_LENGTH'] = $request->getHeader('Content-Length');
         $env['CONTENT_TYPE'] = $request->getHeader('Content-Type');
     }
     if ($request->getHeader('Https')) {
         $env['HTTPS'] = 1;
     }
     foreach ($request->getHeaders() as $name => $value) {
         $variable = 'HTTP_' . str_replace('-', '_', strtoupper($name));
         $env[$variable] = $value;
     }
     return $env;
 }