|
3 | 3 |
|
4 | 4 | use React\Http\Response; |
5 | 5 | use React\Http\Request; |
| 6 | +use Application\HTTP\App; |
6 | 7 |
|
7 | 8 | define("ROOT", dirname(__DIR__)); |
8 | 9 |
|
|
13 | 14 | $port = 15155; |
14 | 15 | $host = 'localhost'; |
15 | 16 |
|
16 | | -foreach($argv AS $arg){ |
17 | | - if($arg === '--no-io'){ |
| 17 | +foreach ($argv as $arg) { |
| 18 | + if ($arg === '--no-io') { |
18 | 19 | $noFsIO = true; |
19 | | - } |
20 | | - elseif(strpos($arg, '=') !== false){ |
| 20 | + } elseif (strpos($arg, '=') !== false) { |
21 | 21 | list($name, $value) = explode('=', $arg); |
22 | | - if($name === '--port'){ |
| 22 | + if ($name === '--port') { |
23 | 23 | $port = $value; |
24 | | - } |
25 | | - elseif($name === '--host'){ |
| 24 | + } elseif ($name === '--host') { |
26 | 25 | $host = $value; |
27 | 26 | } |
28 | 27 | } |
29 | 28 | } |
30 | 29 |
|
31 | 30 | $app = new App($noFsIO); |
32 | | -$handler = function ($request, Response $response) use ($app){ |
| 31 | +$handler = function ($request, Response $response) use ($app) { |
33 | 32 | $start = microtime(1); |
34 | 33 | printf("%s %s\n", $request->getMethod(), $request->getPath()); |
35 | 34 | if($request->getMethod() !== 'POST'){ |
|
42 | 41 | $body->data = ""; |
43 | 42 | $body->receivedLength = 0; |
44 | 43 | $body->dataLength = $headers['Content-Length']; |
45 | | - $request->on("data", function($data) use ( |
46 | | - $request, $response, $app, $body, $start |
47 | | - ){ |
| 44 | + $request->on("data", function ($data) use ( |
| 45 | + $request, |
| 46 | + $response, |
| 47 | + $app, |
| 48 | + $body, |
| 49 | + $start |
| 50 | + ) { |
48 | 51 | $body->data .= $data; |
49 | 52 | $body->receivedLength += strlen($data); |
50 | 53 | if($body->receivedLength >= $body->dataLength){ |
|
0 commit comments