Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frameworks/workerman/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"workerman/workerman": "^5"
"workerman/workerman": "dev-master"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 5 additions & 3 deletions frameworks/workerman/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"repo": "https://github.com/walkor/Workerman",
"enabled": true,
"tests": [
"pipelined",
"baseline",
"noisy",
"pipelined",
"limited-conn",
"json",
"upload",
"compression",
"limited-conn"
"noisy",
"mixed"
]
}
20 changes: 12 additions & 8 deletions frameworks/workerman/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Workerman\Worker;
use Workerman\Protocols\Http\Response;
use Workerman\Connection\TcpConnection;

require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/db.php';
Expand All @@ -13,6 +14,9 @@
// 1 process per CPU core
$http_worker->count = (int) shell_exec('nproc');

// Increase max package size to 30MB for file upload test
TcpConnection::$defaultMaxPackageSize = 30 * 1024 * 1024;

// benchmark data
define('JSON_DATA', json_decode(file_get_contents('/data/dataset.json'), true));
define('LARGE_JSON', largeJson());
Expand Down Expand Up @@ -57,9 +61,9 @@ function largeJson()
$connection->headers = ['Content-Type' => 'application/json'];
return $connection->send(json_encode(['items' => $total, 'count' => count($total)]));

// case '/upload':
// $connection->headers = ['Content-Type' => 'text/plain'];
// return $connection->send(strlen($request->rawBody()));
case '/upload':
$connection->headers = ['Content-Type' => 'text/plain'];
return $connection->send(strlen($request->rawBody()));

case '/compression':
if (str_contains($request->header('Accept-Encoding', ''), 'gzip')) {
Expand All @@ -83,11 +87,11 @@ function largeJson()
);
}

// Serve static files
// if (str_starts_with($request->path(), '/static/')) {
// $response = (new Response())->withFile('/data' . $request->path());
// return $connection->send($response);
// }
//Serve static files
if (str_starts_with($request->path(), '/static/')) {
$response = (new Response())->withFile('/data' . $request->path());
return $connection->send($response);
}

return $connection->send(new Response(
404,
Expand Down