diff --git a/frameworks/workerman/composer.json b/frameworks/workerman/composer.json index 9a05e7e6..d0c8ca7e 100644 --- a/frameworks/workerman/composer.json +++ b/frameworks/workerman/composer.json @@ -1,6 +1,6 @@ { "require": { - "workerman/workerman": "^5" + "workerman/workerman": "dev-master" }, "autoload": { "psr-4": { diff --git a/frameworks/workerman/meta.json b/frameworks/workerman/meta.json index c023efe6..b88df84f 100644 --- a/frameworks/workerman/meta.json +++ b/frameworks/workerman/meta.json @@ -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" ] } diff --git a/frameworks/workerman/server.php b/frameworks/workerman/server.php index 420fb8e1..be6af884 100644 --- a/frameworks/workerman/server.php +++ b/frameworks/workerman/server.php @@ -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'; @@ -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()); @@ -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')) { @@ -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,