Skip to content

Commit d356bf1

Browse files
committed
fixed large content receiving bugs
1 parent 31ddc19 commit d356bf1

30 files changed

Lines changed: 1344 additions & 437 deletions

bin/behat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../vendor/behat/behat/bin/behat

bin/indexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/** @var $command \Command\CommandInterface */
1111

1212
$arguments = [];
13-
$router = new Router;
13+
$router = new \Router;
1414

1515
$command = $router->getCommand($argv[1]);
1616

bin/peridot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../vendor/peridot-php/peridot/bin/peridot

bin/server.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require "app/config/bin.php";
5+
require "vendor/autoload.php";
6+
$app = new App;
7+
$handler = function ($request, $response) use ($app){
8+
$start = microtime(1);
9+
printf("%s %s\n", $request->getMethod(), $request->getPath());
10+
$headers = $request->getHeaders();
11+
$body = new \stdClass;
12+
$body->data = "";
13+
$body->receivedLength = 0;
14+
$body->dataLength = $headers['Content-Length'];
15+
$request->on("data", function($data) use (
16+
$request, $response, $app, $body, $start
17+
){
18+
$body->data .= $data;
19+
$body->receivedLength += strlen($data);
20+
if($body->receivedLength >= $body->dataLength){
21+
$response->end($app->handle($request, $response, $body->data));
22+
printf("Response time: %s\n", microtime(1) - $start);
23+
}
24+
});
25+
};
26+
27+
$loop = React\EventLoop\Factory::create();
28+
$socket = new React\Socket\Server($loop);
29+
$http = new React\Http\Server($socket);
30+
31+
$http->on('request', $handler);
32+
33+
$socket->listen($port);
34+
35+
echo "Started http server on {$port}\n";
36+
37+
$loop->run();

bin/start.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

bin/stop.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@
1616
"mnapoli/php-di": "~4.4",
1717
"sami/sami": "~3.0",
1818
"react/react": "0.4.*"
19+
},
20+
"require-dev": {
21+
"behat/behat": "~3.0",
22+
"peridot-php/peridot": "~1.15",
23+
"peridot-php/leo": "~1.4"
1924
}
2025
}

0 commit comments

Comments
 (0)