public function onRequest()
 {
     $http = self::$serverInstance;
     $kernel = $this->kernel;
     $http->onMessage = function ($connection, $data) use($kernel) {
         //        $http->on('request', function ($request, $response) use($kernel) {
         //            if ($request->server['request_uri'] !== '/favicon.ico') {
         $l_request = new Symfony\Component\HttpFoundation\Request($data['get'], $data['post'], [], $data['cookie'], $data['files'], $data['server']);
         if (0 === strpos($l_request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') && in_array(strtoupper($l_request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))) {
             parse_str($l_request->getContent(), $data);
             $l_request->request = new Symfony\Component\HttpFoundation\ParameterBag($data);
         }
         Illuminate\Http\Request::enableHttpMethodParameterOverride();
         $l_request = Illuminate\Http\Request::createFromBase($l_request);
         $l_response = $kernel->handle($l_request);
         $result = $l_response->getContent();
         foreach ($l_response->headers->allPreserveCase() as $name => $values) {
             Http::header($name . ':' . implode(';', $values));
         }
         //            $l_response->send();
         foreach ($l_response->headers->getCookies() as $cookie) {
             Http::setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
         }
         $kernel->terminate($l_request, $l_response);
         $connection->send($result);
         //            }
     };
 }
예제 #2
0
 public function onRequest()
 {
     $http = self::$serverInstance;
     $kernel = $this->kernel;
     $http->on('request', function ($request, $response) use($kernel) {
         $_SERVER = array_change_key_case($request->server);
         $l_request = new Symfony\Component\HttpFoundation\Request(isset($request->get) ? $request->get : [], isset($request->post) ? $request->post : [], [], isset($request->cookie) ? $request->cookie : [], isset($request->files) ? $request->files : [], $_SERVER, $request->rawContent());
         if (0 === strpos($l_request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') && in_array(strtoupper($l_request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))) {
             parse_str($l_request->getContent(), $data);
             $l_request->request = new Symfony\Component\HttpFoundation\ParameterBag($data);
         }
         Illuminate\Http\Request::enableHttpMethodParameterOverride();
         $l_request = Illuminate\Http\Request::createFromBase($l_request);
         $l_response = $kernel->handle($l_request);
         ob_start();
         $l_response->send();
         $kernel->terminate($l_request, $l_response);
         $result = ob_get_clean();
         $response->end($result);
     });
 }