diff --git a/frameworks/workerman/Dockerfile b/frameworks/workerman/Dockerfile index 2c1d0ad55..54b388d59 100644 --- a/frameworks/workerman/Dockerfile +++ b/frameworks/workerman/Dockerfile @@ -1,12 +1,11 @@ -FROM ubuntu:24.04 +FROM ubuntu:26.04 ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null -RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php > /dev/null && \ - apt-get update -yqq > /dev/null && apt-get upgrade -yqq > /dev/null +RUN apt-get update -yqq > /dev/null && apt-get upgrade -yqq > /dev/null -RUN apt-get install -yqq php8.5-cli php8.5-xml php8.5-zip php8.5-pgsql> /dev/null +RUN apt-get install -yqq zip unzip php8.5-cli php8.5-xml php8.5-zip php8.5-pgsql> /dev/null COPY --from=composer/composer:latest-bin --link /composer /usr/local/bin/composer diff --git a/frameworks/workerman/composer.json b/frameworks/workerman/composer.json index d0c8ca7e6..6729d5065 100644 --- a/frameworks/workerman/composer.json +++ b/frameworks/workerman/composer.json @@ -1,6 +1,6 @@ { "require": { - "workerman/workerman": "dev-master" + "workerman/workerman": "^v5.2.2" }, "autoload": { "psr-4": { diff --git a/frameworks/workerman/meta.json b/frameworks/workerman/meta.json index 15bc3456e..4936ce938 100644 --- a/frameworks/workerman/meta.json +++ b/frameworks/workerman/meta.json @@ -14,6 +14,7 @@ "json", "json-tls", "static", + "static-tls", "api-4", "api-16", "async-db", diff --git a/frameworks/workerman/server.php b/frameworks/workerman/server.php index 6722573d9..1dc0e9015 100644 --- a/frameworks/workerman/server.php +++ b/frameworks/workerman/server.php @@ -68,13 +68,14 @@ $item['total'] = $item['price'] * $item['quantity'] * $m; $total[] = $item; } + $connection->headers = ['Content-Type' => 'application/json']; return $connection->send(json_encode(['items' => $total, 'count' => $count], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); } //Serve static files if (str_starts_with($path, '/static/')) { - $response = (new Response())->withFile('/data' . $path); + $response = new Response()->withFile('/data' . $path); return $connection->send($response); } @@ -106,7 +107,8 @@ $https->onMessage = static function ($connection, $request) { - if(str_starts_with($request->path(), '/json/')) { + $path = $request->path(); + if(str_starts_with($path, '/json/')) { $count = explode('/', $request->path())[2]; $m = $request->get('m', 1); $total = []; @@ -120,6 +122,12 @@ return $connection->send(json_encode(['items' => $total, 'count' => $count], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); } + //Serve static files + if (str_starts_with($path, '/static/')) { + $response = new Response()->withFile('/data' . $path); + return $connection->send($response); + } + return $connection->send(new Response( 404, ['Content-Type' => 'text/plain'],