diff --git a/frameworks/paozhu/Dockerfile b/frameworks/paozhu/Dockerfile index e08da8f5d..8e1c531fc 100644 --- a/frameworks/paozhu/Dockerfile +++ b/frameworks/paozhu/Dockerfile @@ -29,7 +29,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # Pinned so mini_project.sh, the controller generator and the CMake entry point # stay in sync with the scaffold this entry was written against. -ARG PAOZHU_REF=ecc3e6c9bb219177d5b9e71cbc28753a2196448f +ARG PAOZHU_REF=2f8f3d3bbe15a507ecbf442c681bf7138315a0dd WORKDIR /paozhu # Prefer a source archive shipped in the build context (offline / slow-GitHub # environments); otherwise fetch the pinned revision from codeload. The direct diff --git a/frameworks/paozhu/cost_define.h b/frameworks/paozhu/cost_define.h index 45fa4576b..5b85b5693 100755 --- a/frameworks/paozhu/cost_define.h +++ b/frameworks/paozhu/cost_define.h @@ -173,6 +173,11 @@ #define CONST_HTTP1_KEEPALIVE_MAX_REQUESTS 1000 // ---- HTTP/2 单连接资源上限(http2_parse.cpp)---- +// 对外承诺的单连接并发流上限(SETTINGS_MAX_CONCURRENT_STREAMS)。 +// 超限时对触发上限的那条流回 RST_STREAM(REFUSED_STREAM),连接保留。 +// Advertised per-connection concurrent stream limit. Exceeding it resets only the offending stream with REFUSED_STREAM. +#define CONST_HTTP2_MAX_CONCURRENT_STREAMS 100 + // 单连接上「未完成头部块」+「已建流但 body 未结束」的流数量上限。 // server.cpp 的 steam_count 只统计「已派发」的流,客户端只发 HEADERS 不开 END_STREAM // 时永远不会触发,因此这里必须再卡一道,否则 http_data/http_post_data 可被撑爆。 @@ -202,8 +207,16 @@ // grow per-connection encoder memory without bound. Separate from the decoder ceiling above. #define CONST_HTTP2_ENCODER_TABLE_CAP 4096 -// HPACK encoder dynamic table switch for response headers. Define to enable Indexed representation; -// comment out to fall back to Literal without Indexing (0000xxxx). +// HPACK encoder dynamic table switch for response headers. Define to enable Indexed +// representation; comment out to fall back to Literal without Indexing (0000xxxx) — that +// is still conformant HPACK (RFC 7541 §6.2.2), just larger header blocks, and it needs no +// dynamic table size update signal. The status line and the legacy item/item2 builders +// stay table-neutral in both modes (fixed 2026-11-23), so commenting this out is a full +// fallback. +// 响应头方向的 HPACK 编码器动态表开关。定义后可用 Indexed 表示;注释掉即整体回退到 +// Literal without Indexing(0000xxxx)——那仍是合规编码,只是头块更大,且不再需要 Size Update +// 信号。状态行与旧 item/item2 在两种档位下都不碰动态表(2026-11-23 修复),所以注释掉本宏 +// 就是完整回退。 #define PAOZHU_HPACK_ENCODER_DYNAMIC_TABLE 1 // Connection-level error COMPRESSION_ERROR (RFC 9113 §7 / RFC 7541). GOAWAY with this code diff --git a/frameworks/paozhu/meta.json b/frameworks/paozhu/meta.json index 386c9421d..7dafb1e34 100644 --- a/frameworks/paozhu/meta.json +++ b/frameworks/paozhu/meta.json @@ -1,7 +1,7 @@ { "display_name": "paozhu", "language": "C++", - "type": "experimental", + "type": "flagship", "mode": "standard", "completeness": { "routing": true, @@ -13,6 +13,8 @@ "description": "Paozhu C++20 web framework on standalone Asio, built from the upstream mini_project.sh clean scaffold. Annotated controller routes answer /baseline11, /baseline2, /pipeline, /echo, /json/{count}?m={multiplier}, /delay/{ms}, /async-db?min=&max=&limit= and /fortunes; the dataset is parsed once at startup and serialized per request, /echo returns the raw request body byte-for-byte, and the DB routes use paozhu's own async Postgres driver. /static/* is served by the framework's native static path from the mounted /data/static (wwwpath=/data) with an on-disk compression cache pre-warmed at startup. Two server instances share the image: plaintext HTTP/1.1 on :8080 and ALPN h2 on :8443, plus a second instance whose TLS listener on :8081 advertises only http/1.1 for json-tls, 8gbit and static-tls and whose cleartext :8082 listener serves h2c prior-knowledge for baseline-h2c and json-h2c.", "repo": "https://github.com/hggq/paozhu", "enabled": true, + "resilience": true, + "spec": ["h1", "h2", "ws"], "tests": [ "baseline","async","latency-1m", "latency-10k", "pipelined", @@ -20,6 +22,8 @@ "json-comp", "json-tls", "8gbit", + "connections-1m", + "connections-1m-tls", "baseline-h2", "static-h2", "static-tls", diff --git a/frameworks/paozhu/src/conf/server-h1.conf b/frameworks/paozhu/src/conf/server-h1.conf index 7c435fca0..a829de495 100644 --- a/frameworks/paozhu/src/conf/server-h1.conf +++ b/frameworks/paozhu/src/conf/server-h1.conf @@ -9,6 +9,7 @@ [default] threadmax = 1024 threadmin = 5 +socket_accept_num = 4 ;hardware_concurrency()/16 cothreadnum = 0 ; 0 = auto (host cores) per_ioc_thread_num = 1 ; orm_ioc_num = 4 ;ORM io_context num; diff --git a/frameworks/paozhu/src/conf/server.conf b/frameworks/paozhu/src/conf/server.conf index 365dea4ff..b91c87a22 100644 --- a/frameworks/paozhu/src/conf/server.conf +++ b/frameworks/paozhu/src/conf/server.conf @@ -4,6 +4,7 @@ [default] threadmax = 1024 threadmin = 5 +socket_accept_num = 4 ;hardware_concurrency()/16 cothreadnum = 0 ; 0 = auto (host cores) per_ioc_thread_num = 1 ; orm_ioc_num = 4 ;ORM io_context num; diff --git a/frameworks/paozhu/src/controller/src/arena.cpp b/frameworks/paozhu/src/controller/src/arena.cpp index 82afa3675..8e71de1cd 100644 --- a/frameworks/paozhu/src/controller/src/arena.cpp +++ b/frameworks/paozhu/src/controller/src/arena.cpp @@ -570,6 +570,56 @@ asio::awaitable arena_echo(std::shared_ptr peer) co_return ""; } +// HttpArena protocol-compliance route (h1/h2 suites). +// GET/HEAD: fixed text body >= 5 bytes (h2spec skips a flow-control test below 5). +// POST: byte-for-byte raw body echo, through the same parser API as /echo. +// OPTIONS: 200 with Allow; the core closes the connection if a body was sent +// rather than leave unread bytes that could be parsed as a second request. +//@urlpath(null,spec) +asio::awaitable arena_spec(std::shared_ptr peer) +{ + peer->status(200); + if (peer->method == static_cast(HEAD_METHOD::HEAD) || + peer->method == static_cast(HEAD_METHOD::GET)) + { + peer->type("text/plain"); + peer->output = "spec ok"; + } + else if (peer->method == static_cast(HEAD_METHOD::POST)) + { + peer->type("application/octet-stream"); + peer->output = raw_body(peer); + } + else if (peer->method == static_cast(HEAD_METHOD::OPTIONS)) + { + peer->set_header("Allow", "GET, HEAD, POST, OPTIONS"); + peer->type("text/plain"); + peer->output.clear(); + } + co_return ""; +} + +// Header echo: one `Name: Value` line per received header, in any order/case. +// Read the body even though it is discarded, so POST bodies go through the +// normal parser path and any >2MB spilled temp file is cleaned up. +//@urlpath(null,spec/headers) +asio::awaitable arena_spec_headers(std::shared_ptr peer) +{ + raw_body(peer); + peer->status(200); + peer->type("text/plain"); + std::string out; + for (const auto &kv : peer->header) + { + out += kv.first; + out += ": "; + out += kv.second; + out.push_back('\n'); + } + peer->output = std::move(out); + co_return ""; +} + //@urlpath(null,baseline11) asio::awaitable arena_baseline11(std::shared_ptr peer) {