Ejemplo n.º 1
0
 public function parseRequest($data)
 {
     list($headers, $bodyBuffer) = explode("\r\n\r\n", $data, 2);
     $factory = new RequestFactory();
     $parsed = $factory->parseMessage($headers . "\r\n\r\n");
     $parsedQuery = array();
     if (0 === strpos($parsed['parts']['query'], '?')) {
         $query = substr($parsed['parts']['query'], 1);
         parse_str($query, $parsedQuery);
     }
     $request = new Request($parsed['method'], $parsed['parts']['path'], $parsedQuery, $parsed['protocol_version'], $parsed['headers']);
     return array($request, $bodyBuffer);
 }