diff --git a/CHANGELOG.md b/CHANGELOG.md index a6694e72..20f4b227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,9 @@ `v1.7.4`;`1.7.5`–`1.7.6` 折进 `v1.8.0`;`1.8.1`、`1.8.2`、`1.8.3`、`1.8.4`、`1.8.5`、`1.8.6`、`1.8.7`、`1.8.8`、`1.8.9`、`1.8.10` 是它之后的补丁版, `1.8.11`–`1.8.15` 折进 `v1.9.0`,`v1.9.1` 是它之后的补丁版(不折叠、直接发布); `1.10.0-dev` 折进 `v1.10.0`(已发布);`1.11.0-dev` 已折进 `v1.11.0`(已发布);`1.12.0-dev` 折进 `v1.12.0`(已发布);`1.12.1-dev` 已折进 `v1.12.1`(已发布);`1.13.0-dev` 已折进 `v1.13.0`(已发布); -`1.13.1-dev` 已折进 `v1.13.1`(已发布)。想按时间线读,翻到最后的「逐个版本」。 +`1.13.1-dev` 已折进 `v1.13.1`(已发布);`1.13.2-dev` 是当前开发档,未打 tag。想按时间线读,翻到最后的「逐个版本」。 -当前源码树是 **1.13.1**(发布版) —— 即 `src/uvcpp/uvcpp_version.h` 里 `UVCPP_VERSION_STRING` +当前源码树是 **1.13.2-dev**(开发版) —— 即 `src/uvcpp/uvcpp_version.h` 里 `UVCPP_VERSION_STRING` 报告的那个串。已打过的 tag:`v1.0.0`、`v1.1.0`、`v1.2.0`、`v1.3.0`、`v1.4.0`、`v1.5.0`、`v1.6.0`、`v1.6.1`、`v1.6.2`、`v1.6.3`、`v1.6.4`、`v1.7.0`、`v1.7.4`、`v1.8.0`、`v1.8.1`、`v1.8.2`、`v1.8.3`、`v1.8.4`、`v1.8.5`、`v1.8.6`、`v1.8.7`、`v1.8.8`、`v1.8.9`、`v1.8.10`、`v1.9.0`、`v1.9.1`、`v1.10.0`、`v1.11.0`、`v1.12.0`、`v1.12.1`、`v1.13.0`。 其中若干条来自本仓第一位外部贡献者 [@sercebr](https://github.com/sercebr) 报的 issue。 @@ -253,6 +253,18 @@ ### QUIC 传输(net 层) +- **QUIC 的 ALPN 无交集按 RFC 9001 §8.1 回 fatal `no_application_protocol`** + (`1.13.2-dev`):QUIC 没有明文模式,客户端宣告的名单一个都挑不中时不能像 + TCP TLS 那样以"没有 ALPN"继续握手。`uvcpp_ssl_context::set_alpn_select_protos()` + 新增 `alpn_mismatch` 档位(默认 `NOACK` 保持 TCP 老行为;QUIC 服务端自动用 + `FATAL`),无交集时回 alert 120,`h3spec` 的 TLS 8.1 由红转绿。`quic_api_func` + 新增一条真握手用例钉住"无交集必须握手失败且 `on_alpn` 不响"。 +- **缺 `quic_transport_parameters` 的 ClientHello 按 RFC 9001 §8.2 拒绝** + (`1.13.2-dev`):OpenSSL 3.5 的 QUIC TLS 不会因为 ClientHello 少了这个扩展 + 而失败,ngtcp2 随后要写 1-RTT 包时 `negotiated_version` 仍是 0,在 + `conn_write_pkt` 的断言上 abort —— 合规套件的「套件期间服务器崩溃」正是它。 + 服务端现在在 ClientHello 阶段就回 TLS alert `missing_extension`;TLS 层的 + 其它失败也按 `CRYPTO_ERROR | alert` 上报,而不是笼统的 PROTOCOL_VIOLATION。 - **连接只读统计**(`1.8.15-dev`):`uvcpp_quic_connection::stats()` 给出 RTT (最近/最小/平滑/偏差,微秒)、`cwnd` / `ssthresh` / `bytes_in_flight` 与收发 包、字节、丢包计数(ngtcp2 `ngtcp2_conn_get_conn_info()`;`pkt_sent` 那一组是 @@ -332,7 +344,7 @@ `doc/quic-guide.md` §8 的措辞是"契约改了",不是"缺口补了"(`1.4.1`) - **那一对私有头。** `uvcpp_quic_session.h` 里是 `ngtcp2_conn*`、`SSL*` 与 `ngtcp2_path_storage`,字段布局跟着 ngtcp2 的版本走 —— 它是第二个私有头,与 - `uvcpp_quic_ngtcp2.h` 并列。两个都不安装(`CMakeLists.txt:3756-3756`)、打包也排除 + `uvcpp_quic_ngtcp2.h` 并列。两个都不安装(`CMakeLists.txt:3888-3888`)、打包也排除 (`tests/tools/package_release.py` 的 `PRIVATE_HEADERS`);量过: `cmake --install build-quic --prefix /tmp/inst` 落进 `include/quic/` 的正好是那 四个公开头(`1.4.1`) @@ -480,6 +492,28 @@ ### HTTP/3(web 层) +- **控制流的五处 RFC 9114 校验补齐**(`1.13.2-dev`):nghttp3 1.18(1.19.0 与 + master 也未改)在构建副本上打补丁 —— 重复 SETTINGS 标识回 `H3_SETTINGS_ERROR`; + 控制流上的 `CANCEL_PUSH`(未发过 `MAX_PUSH_ID` 时任何 push ID 都不允许)回 + `H3_ID_ERROR`;`MAX_PUSH_ID` 下降同样回 `H3_ID_ERROR`;`MAX_PUSH_ID` 的 varint + 之后还有字节回 `H3_FRAME_ERROR`;控制流帧长超过 1 MiB 回 `H3_EXCESSIVE_LOAD`。 + `NGHTTP3_VERSION` 仍指向上游 tag,nghttp3 的公开头与 ABI 不变;每处替换都带 + 定位断言。`web_app_h3_http_func` 新增五条真 QUIC 回归(关闭码 + 0x0109/0x0108/0x0108/0x0106/0x0107,补丁前 8 个断言失败),h3spec 0.1.15 + 全量 86 例 **0 失败**、1 pending。 +- **对端单向关键流「类型码与 FIN 同读」时按 H3_CLOSED_CRITICAL_STREAM 收场** + (`1.13.2-dev`):nghttp3 的 `nghttp3_conn_read_uni()` 认完流类型之后,若这次 + 读已经没有剩余字节就直接返回,**不看 `fin`**;本层再把「FIN 已交」记成既成 + 事实,于是 QPACK 解码器/编码器流或控制流被对端「开完即关」时,连接留了下来。 + 收全的 peer 单向流现在补一次零长度读,把 FIN 单独交给 nghttp3。`web_app_h3_http_func` + 新增一条真 QUIC 回归(0x03 + FIN → 连接以 0x0104 关闭),h3spec 的 + decoder-stream-closed 用例由红转绿(全量 86 例:6 失败 → 5 失败,1 pending)。 +- **QPACK 编码端动态表策略可配**(`1.13.2-dev`):`uvcpp_h3_connection` 与 + `uvcpp_http_server` 新增 `set_qpack_encoder_table_policy()`。默认 + `disabled`(容量 0,静态表 + 字面量),与官方 H3 验证形态一致;可选 + `automatic`(nghttp3 默认值)或 `fixed`(显式容量,0 等同 disabled)。必须在 + 连接 `start()` 前设置;服务器级设置只影响此后新建的连接。该开关只影响本端 + 响应头编码,不改变对端 `SETTINGS_QPACK_MAX_TABLE_CAPACITY` 的接收上限。 - **WebTransport 的建立时序、关闭与排空**(`1.8.11-dev`):`accept()` 之后才把 `on_open` 交给应用(此前应用在会话真正可用之前就拿到了它);`WT_DRAIN_SESSION` 带 `on_drain` 回调;`SESSION_GONE` 重置关联流;客户端等 2xx 再开流(早到的帧 @@ -789,7 +823,7 @@ `std::string` / `uint32_t` / `const char*`,**不认识连接、不认识响应**,所以 `UVCPP_BUILD_WEB=OFF` 时照编照装。`uvcpp_grpc_server.{h,cpp}` 把上面那半接到 `uvcpp_http_server` 上,它的每一个参数都是 web 层的类型,web 关掉时**从构建与安装 - 两处都摘掉**(`CMakeLists.txt:2400-2402`、`CMakeLists.txt:3648-3653`)—— + 两处都摘掉**(`CMakeLists.txt:2532-2534`、`CMakeLists.txt:3780-3785`)—— 实测:`-DUVCPP_BUILD_WEB=OFF` 的树上 `src/grpc/uvcpp_grpc.cpp` 照编、装到前缀里的 只有 `include/grpc/uvcpp_grpc.h`;`build-capi-all` 上前缀里两个头都在。 **不加 `UVCPP_ENABLE_GRPC`**:两半的依赖是死的,多一个旋钮只会多一个能与 @@ -1597,7 +1631,7 @@ ODBC** 四个后端,结果行按表取(列名或列号)。**默认关**( - **流水线里末条的 `Connection: close` 会把前面几条的响应一起带走**(`1.6.46-dev`)。 HTTP/1.1 流水线(一次读缓冲里多条请求)下,**异步响应**的第 1 条在序列化时问的是 `uvcpp_http_server` 里那句 `ctx.parser->should_keep_alive()` - (`src/web/uvcpp_http_server.cpp:1719-1719`),而 llhttp 的 flags 是**连接级**的、 + (`src/web/uvcpp_http_server.cpp:1846-1846`),而 llhttp 的 flags 是**连接级**的、 属于「最近一条解析完的报文」—— 一个 `execute()` 会把整批 N 条一次解完,所以第 1 条 读到的是**第 N 条**的结论。末条写 `close` ⇒ 服务器在第 1 条响应之后关连接,第 2..N 条 响应随连接一起消失(服务端那时在 `src/webapp/uvcpp_web_app.cpp:2909-2909` 打 @@ -1610,7 +1644,7 @@ ODBC** 四个后端,结果行按表取(列名或列号)。**默认关**( `on_http_request()` 里 `take_from()` 早把头部整表搬成了请求自己的,`is_keep_alive()` 读的就是这一条的 `connection`,与解析器走到哪儿无关;规则与 llhttp 逐字一致 (1.1 默认保持、1.0 默认关闭),也就是 RFC 9112 §9.6 的「每条报文自己的连接选项」。 - HTTP 层本来就认显式头(`src/web/uvcpp_http_server.cpp:1720-1723`)、`begin_stream` 也认(`src/web/uvcpp_http_server.cpp:1845-1850`),所以 + HTTP 层本来就认显式头(`src/web/uvcpp_http_server.cpp:1847-1850`)、`begin_stream` 也认(`src/web/uvcpp_http_server.cpp:1972-1977`),所以 **整包 / 尾随头 / 流式**三条出口一并覆盖,且 `handler` 自己设过 `connection` 的 仍然说了算。放在「发送前」而不是「派发时」:处理函数跑之前响应表必须还是空的 (那条既有约定由 `web_app_app_func.cpp` 的 `response_header_capacity_reused` 正对照 @@ -3886,17 +3920,17 @@ ODBC** 四个后端,结果行按表取(列名或列号)。**默认关**( dlopen 只是把这条路变成**每个装了 libpq 的人**的默认路径。)把我们的嵌入依赖藏起来, libpq 就会解析到**系统**那份、与它自己的 libcrypto 自洽。 - 修法一(`CMakeLists.txt:3031-3073`,`UNIX AND NOT APPLE`,只给共享目标 + 修法一(`CMakeLists.txt:3163-3205`,`UNIX AND NOT APPLE`,只给共享目标 `uvcpp`/`uvcpp_s`):`target_link_options(… PRIVATE "LINKER:--exclude-libs,ALL")`。 它只藏**来自静态归档**的符号,而这两个目标是 - `add_library(uvcpp SHARED ${UVCPP_SOURCES} …)`(`CMakeLists.txt:2636-2636`) + `add_library(uvcpp SHARED ${UVCPP_SOURCES} …)`(`CMakeLists.txt:2768-2768`) **直接拿我们自己的目标文件**建的、不经归档 ⇒ 我们自己的 API 与 `uvcpp_c_*` 那套 C ABI 照样导出。只给共享目标加是因为静态库没有导出表,藏了反而让 `uvcpp_a` 的消费者 在最终链接时找不到本该由我们提供的符号;只给 ELF 加是因为 Apple 的 ld 没有这个选项 (那边是 `-exported_symbols_list`),而发布腿里本来也没有 macOS。 修法二:`uvcpp_yyjson` 是 **OBJECT** 库,它的目标文件经 - `$`(`CMakeLists.txt:3379-3379`)**直接进最终链接、也不经归档** ⇒ + `$`(`CMakeLists.txt:3511-3511`)**直接进最终链接、也不经归档** ⇒ 上面那条对它无效(实测加不加都是 43 个 `yyjson_*`)。那边改用 `C_VISIBILITY_PRESET hidden` **加** `target_compile_definitions(uvcpp_yyjson PRIVATE yyjson_api=)`。**第二半是承重的**:上游 `yyjson.h` 给每个公开函数**显式**贴了 @@ -3949,7 +3983,7 @@ ODBC** 四个后端,结果行按表取(列名或列号)。**默认关**( `CMakeLists.txt:586-586`),而不是指望"没调用 = 没找到"。取源码那条支路一个字没改: 选项开着 ⇒ 跳过发现 ⇒ `BROTLIENC_LIB` 仍是 `NOTFOUND` ⇒ 自然落进那一支 ⇒ 那里照旧 `set(UVCPP_BROTLI_FROM_SOURCE TRUE)`(`CMakeLists.txt:664-664`),链接段 - (`CMakeLists.txt:3215-3215`)也就照旧按 `$` 取静态库。默认值一个都没 + (`CMakeLists.txt:3347-3347`)也就照旧按 `$` 取静态库。默认值一个都没 动,所以既有使用者的行为逐字节不变。 判据(本机,`build-brotli2`:`-DUVCPP_ENABLE_BROTLI=ON @@ -4135,7 +4169,7 @@ ODBC** 四个后端,结果行按表取(列名或列号)。**默认关**( `flags` = `web` 加一个 `-DUVCPP_ENABLE_YYJSON=ON`,四道门禁串 `UVCPP_ENABLE_YYJSON:BOOL=ON` / `yyjson integrated` / `Including yyjson module in build` / `test_yyjson_doc_func`;装包表与 `web` **逐字相同**(yyjson 走 FetchContent - —— `CMakeLists.txt:2134`,`GIT_TAG` 钉在 `YYJSON_VERSION` —— **不发包管理器**), + —— `CMakeLists.txt:2266`,`GIT_TAG` 钉在 `YYJSON_VERSION` —— **不发包管理器**), 这样两边红绿不同只可能归因到那个开关。 **为什么 macOS 有一格、而 `wsdl` 没有**:`ci-guide.md` §1 给缺 macOS `wsdl` 的理由是 diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fc9ad9e..edcf65ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1639,6 +1639,138 @@ if(UVCPP_ENABLE_HTTP3) file(WRITE "${_uvcpp_nghttp3_src}/CMakeLists.txt" "${_uvcpp_nghttp3_cml}") endif() + # --------------------------------------------------------------- + # [uvcpp] H3 控制流校验补丁 —— h3spec 0.1.15 的五个用例 + # --------------------------------------------------------------- + # 这五处都在 nghttp3 1.18 的 `read_control()` / + # `nghttp3_conn_on_settings_entry_received()` 里;上游 1.19.0 和 master + # 至今也没改(1.19.0 只补了 PRIORITY_UPDATE 的缓冲上限)。 + # + # 1. 同一个 SETTINGS 标识出现两次:源码留着 `TODO Check for + # duplicates`,重复标识被静默接受。RFC 9114 7.2.4 允许按 + # H3_SETTINGS_ERROR 处理,h3spec 要求这个错误。 + # 2. 控制流上的 CANCEL_PUSH 一律回 H3_FRAME_UNEXPECTED;服务端没发过 + # MAX_PUSH_ID 时任何 push ID 都不允许,RFC 9114 7.2.3 要求 + # H3_ID_ERROR。 + # 3. MAX_PUSH_ID 下降回 H3_FRAME_ERROR,RFC 9114 7.2.7 要求 + # H3_ID_ERROR。 + # 4. MAX_PUSH_ID 的 varint 之后还有字节时被忽略,RFC 9114 7.1 要求 + # H3_FRAME_ERROR。 + # 5. 控制流帧长没有上限:声明 1 GiB 的帧被照单全收。RFC 9114 7.1 + # 允许按 H3_EXCESSIVE_LOAD 拒绝,h3spec 的 "MUST NOT buffer an + # over-long frame" 要求这个错误。 + # + # 只改构建目录里的副本(`_deps/uvcpp-nghttp3-src`),`NGHTTP3_VERSION` + # 仍指向上游 tag;改的都是库内部实现,nghttp3 的公开头文件与 ABI 不变。 + # 每个替换都带定位断言:上游改过这些行时配置期直接报错,不会静默空转。 + set(_uvcpp_nghttp3_hdr "${_uvcpp_nghttp3_src}/lib/nghttp3_conn.h") + set(_uvcpp_nghttp3_impl "${_uvcpp_nghttp3_src}/lib/nghttp3_conn.c") + + file(READ "${_uvcpp_nghttp3_hdr}" _uvcpp_h3h) + string(REPLACE "\r\n" "\n" _uvcpp_h3h "${_uvcpp_h3h}") + string(FIND "${_uvcpp_h3h}" "[uvcpp] settings_ids" _uvcpp_h3hit) + if(_uvcpp_h3hit EQUAL -1) + set(_uvcpp_h3_h_anchor [[ int64_t max_stream_id_bidi;]]) + string(FIND "${_uvcpp_h3h}" "${_uvcpp_h3_h_anchor}" _uvcpp_h3hit) + if(_uvcpp_h3hit EQUAL -1) + message(FATAL_ERROR + "nghttp3 补丁没打上:nghttp3_conn.h 里找不到 max_stream_id_bidi 声明") + endif() + set(_uvcpp_h3_h_repl [[ int64_t max_stream_id_bidi; + + /* [uvcpp] settings_ids are the identifiers already seen in the peer's + SETTINGS frame; settings_idlen is the number of used entries. */ + uint64_t settings_ids[8]; + size_t settings_idlen;]]) + string(REPLACE "${_uvcpp_h3_h_anchor}" "${_uvcpp_h3_h_repl}" + _uvcpp_h3h "${_uvcpp_h3h}") + file(WRITE "${_uvcpp_nghttp3_hdr}" "${_uvcpp_h3h}") + endif() + + file(READ "${_uvcpp_nghttp3_impl}" _uvcpp_h3c) + string(REPLACE "\r\n" "\n" _uvcpp_h3c "${_uvcpp_h3c}") + string(FIND "${_uvcpp_h3c}" "[uvcpp] settings_ids" _uvcpp_h3hit) + if(_uvcpp_h3hit EQUAL -1) + set(_uvcpp_h3_a1 [[ /* TODO Check for duplicates */]]) + set(_uvcpp_h3_r1 [[ /* [uvcpp] settings_ids: RFC 9114 7.2.4 says a repeated setting + identifier is an error. Track the identifiers of this SETTINGS frame. */ + { + size_t i; + + for (i = 0; i < conn->rx.settings_idlen; ++i) { + if (conn->rx.settings_ids[i] == (uint64_t)ent->id) { + return NGHTTP3_ERR_H3_SETTINGS_ERROR; + } + } + + if (conn->rx.settings_idlen < + sizeof(conn->rx.settings_ids) / sizeof(conn->rx.settings_ids[0])) { + conn->rx.settings_ids[conn->rx.settings_idlen++] = (uint64_t)ent->id; + } + }]]) + string(FIND "${_uvcpp_h3c}" "${_uvcpp_h3_a1}" _uvcpp_h3hit) + if(_uvcpp_h3hit EQUAL -1) + message(FATAL_ERROR + "nghttp3 补丁没打上:nghttp3_conn.c 里找不到重复 SETTINGS 检查的锚点") + endif() + string(REPLACE "${_uvcpp_h3_a1}" "${_uvcpp_h3_r1}" _uvcpp_h3c "${_uvcpp_h3c}") + + set(_uvcpp_h3_a2 [[ rstate->left = rvint->acc; + nghttp3_varint_read_state_reset(rvint); + + if (!(conn->flags & NGHTTP3_CONN_FLAG_SETTINGS_RECVED)) {]]) + set(_uvcpp_h3_r2 [[ rstate->left = rvint->acc; + nghttp3_varint_read_state_reset(rvint); + + /* [uvcpp] Refuse an unbounded control-stream frame (RFC 9114 7.1). */ + if (rstate->left > (uint64_t)1048576) { + return NGHTTP3_ERR_H3_EXCESSIVE_LOAD; + } + + if (!(conn->flags & NGHTTP3_CONN_FLAG_SETTINGS_RECVED)) {]]) + string(FIND "${_uvcpp_h3c}" "${_uvcpp_h3_a2}" _uvcpp_h3hit) + if(_uvcpp_h3hit EQUAL -1) + message(FATAL_ERROR + "nghttp3 补丁没打上:nghttp3_conn.c 里找不到控制帧长度的锚点") + endif() + string(REPLACE "${_uvcpp_h3_a2}" "${_uvcpp_h3_r2}" _uvcpp_h3c "${_uvcpp_h3c}") + + set(_uvcpp_h3_a3 [[ case NGHTTP3_FRAME_CANCEL_PUSH: /* We do not support push */]]) + set(_uvcpp_h3_r3 [[ case NGHTTP3_FRAME_CANCEL_PUSH: + /* [uvcpp] Without MAX_PUSH_ID no push ID is allowed (RFC 9114 + 7.2.3): report H3_ID_ERROR rather than H3_FRAME_UNEXPECTED. */ + return conn->local.uni.max_pushes == 0 + ? NGHTTP3_ERR_H3_ID_ERROR + : NGHTTP3_ERR_H3_FRAME_UNEXPECTED;]]) + string(FIND "${_uvcpp_h3c}" "${_uvcpp_h3_a3}" _uvcpp_h3hit) + if(_uvcpp_h3hit EQUAL -1) + message(FATAL_ERROR + "nghttp3 补丁没打上:nghttp3_conn.c 里找不到 CANCEL_PUSH 的锚点") + endif() + string(REPLACE "${_uvcpp_h3_a3}" "${_uvcpp_h3_r3}" _uvcpp_h3c "${_uvcpp_h3c}") + + set(_uvcpp_h3_a4 [[ if (conn->local.uni.max_pushes > rvint->acc + 1) { + return NGHTTP3_ERR_H3_FRAME_ERROR; + }]]) + set(_uvcpp_h3_r4 [[ /* [uvcpp] MAX_PUSH_ID carries exactly one varint (RFC 9114 7.1), + and a decreasing value is H3_ID_ERROR (7.2.7). */ + if (rstate->left != 0) { + return NGHTTP3_ERR_H3_FRAME_ERROR; + } + + if (conn->local.uni.max_pushes > rvint->acc + 1) { + return NGHTTP3_ERR_H3_ID_ERROR; + }]]) + string(FIND "${_uvcpp_h3c}" "${_uvcpp_h3_a4}" _uvcpp_h3hit) + if(_uvcpp_h3hit EQUAL -1) + message(FATAL_ERROR + "nghttp3 补丁没打上:nghttp3_conn.c 里找不到 MAX_PUSH_ID 的锚点") + endif() + string(REPLACE "${_uvcpp_h3_a4}" "${_uvcpp_h3_r4}" _uvcpp_h3c "${_uvcpp_h3c}") + + file(WRITE "${_uvcpp_nghttp3_impl}" "${_uvcpp_h3c}") + endif() + add_subdirectory("${_uvcpp_nghttp3_src}" "${_uvcpp_nghttp3_bin}" EXCLUDE_FROM_ALL) endif() endfunction() diff --git a/README.md b/README.md index 82a5b3f3..e62bf727 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ libuvcpp logo

-[![version](https://img.shields.io/badge/version-1.13.1-blue.svg)](./RELEASE.md) +[![version](https://img.shields.io/badge/version-1.13.2--dev-blue.svg)](./RELEASE.md) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE) [![CI · Linux · Ubuntu](https://github.com/Antruly/libuvcpp/actions/workflows/ci-linux-ubuntu.yml/badge.svg)](https://github.com/Antruly/libuvcpp/actions/workflows/ci-linux-ubuntu.yml) [![CI · Windows · MSVC](https://github.com/Antruly/libuvcpp/actions/workflows/ci-windows-msvc.yml/badge.svg)](https://github.com/Antruly/libuvcpp/actions/workflows/ci-windows-msvc.yml) @@ -14,7 +14,7 @@ 🔧 Modern C++11 wrapper for [libuv](https://github.com/libuv/libuv) — event-driven I/O with object-oriented APIs, dual-mode async/sync support, HTTP/1.1, WebSocket (RFC 6455), and SSL/TLS. -- **Version**: `1.13.1` — **Author**: `zhuweiye` — **License**: `MIT` +- **Version**: `1.13.2-dev` — **Author**: `zhuweiye` — **License**: `MIT` - **Languages**: [English](./README.md) · [中文](./README.zh.md) ## Download diff --git a/README.zh.md b/README.zh.md index 70b316d1..8f79017f 100644 --- a/README.zh.md +++ b/README.zh.md @@ -2,7 +2,7 @@ libuvcpp logo

-[![版本](https://img.shields.io/badge/version-1.13.1-blue.svg)](./RELEASE.md) +[![版本](https://img.shields.io/badge/version-1.13.2--dev-blue.svg)](./RELEASE.md) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE) [![CI · Linux · Ubuntu](https://github.com/Antruly/libuvcpp/actions/workflows/ci-linux-ubuntu.yml/badge.svg)](https://github.com/Antruly/libuvcpp/actions/workflows/ci-linux-ubuntu.yml) [![CI · Windows · MSVC](https://github.com/Antruly/libuvcpp/actions/workflows/ci-windows-msvc.yml/badge.svg)](https://github.com/Antruly/libuvcpp/actions/workflows/ci-windows-msvc.yml) @@ -14,7 +14,7 @@ 🔧 基于 [libuv](https://github.com/libuv/libuv) 的现代 C++11 封装库 — 面向对象的异步 I/O, 支持双模式(异步回调/同步等待)、HTTP/1.1、WebSocket(RFC 6455)和 SSL/TLS。 -- **版本**:`1.13.1` — **作者**:`zhuweiye` — **许可证**:`MIT` +- **版本**:`1.13.2-dev` — **作者**:`zhuweiye` — **许可证**:`MIT` - **语言**:[English](./README.md) · [中文](./README.zh.md) ## 下载 diff --git a/RELEASE.md b/RELEASE.md index 58d4a0e3..fb2de406 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1760,11 +1760,11 @@ g++ -std=c++11 -g -I include your_app.cpp -L lib -luvcppd -o your_app.exe 引入,它登记的 install 规则引用了一个从未构建的 `libuv.dll`,且它的规则排在 本项目的规则之前 —— 一失败就整体中止,本项目的头文件与库一个都装不出来 (Linux 上没有这个 `.dll`,同一条 install 实测走得通,2026-10-12 验过)。 - 本次的 zip 绕过它、照 `CMakeLists.txt:3389-3877` 的规则手工组装,与 install + 本次的 zip 绕过它、照 `CMakeLists.txt:3521-4009` 的规则手工组装,与 install 只剩**一处**刻意的差异:**libuv 的头放在 `include/` 顶层**(本库的公开头写的是 `#include `,放进 `include/libuv/` 会找不到)。原先还有第二处 —— zip 里 补了 `zlib.h` / `zconf.h`,而 install 规则里没有这一条 —— **2026-10-12 起 - install 规则自己也装这两个头**(`CMakeLists.txt:3891-3894`),两边落到同一个 + install 规则自己也装这两个头**(`CMakeLists.txt:4023-4026`),两边落到同一个 位置,这处差异消失。 ### MSVC 从源码树 / 安装树取头时要加 `/utf-8` —— 头文件侧已修(1.2.0) diff --git a/doc/benchmark.md b/doc/benchmark.md index b46fdd12..42516912 100644 --- a/doc/benchmark.md +++ b/doc/benchmark.md @@ -2501,7 +2501,7 @@ taskset -c 8-15 h2load -i static-h2-uris.txt -H 'Accept-Encoding: br;q=1, gzip;q #### 机制:两条编码走的是同一条命中路径,编码名只在键里 `uvcpp_http_server::apply_compression_for()` 的变体缓存键是 -`编码字符 + 档位字符 + cache_tag`(`src/web/uvcpp_http_server.cpp:2253-2256`)。 +`编码字符 + 档位字符 + cache_tag`(`src/web/uvcpp_http_server.cpp:2380-2383`)。 命中时只做一次 `std::map` 查找 + 一次 `shared_ptr` 递句柄 —— **gzip 与 `br` 是 同一条路径**。所以"开 `br`"在此处的代价是**每个 tag 一次**,不是每请求一次; 反过来说,响应没有 `cache_tag` 时它每请求重压,而 `br` 的编码比 deflate 贵得多。 diff --git a/doc/ci-guide.md b/doc/ci-guide.md index 8014ccda..3cd14d57 100644 --- a/doc/ci-guide.md +++ b/doc/ci-guide.md @@ -287,7 +287,7 @@ removed on 2026-09-17 after measuring them instead of trusting the label: | `test_memory_pool` | "Pre-existing hang (multi-thread pool alloc on Windows)" | 0 failures, ≤1 s per run | Both had been exclusions for defects fixed long before. `test_memory_pool`'s is -documented: it was a missing-DLL-copy bug (see `CMakeLists.txt:3985-3985`), fixed and +documented: it was a missing-DLL-copy bug (see `CMakeLists.txt:4117-4117`), fixed and left in the exclude list anyway. `test_tcp_func`'s dual-loop teardown is most likely the `~uvcpp_tcp_server` fix, which is what removed the two `sleep_for` calls that were joining the worker thread — that is an inference from the @@ -463,7 +463,7 @@ MSVC. MinGW and macOS are the gap (see §1). entry at all and shipped two classes of defect (#35). - **It is `web` plus one switch**, exactly as `zlib-off` is `web` minus one, and its dep list is **byte-identical to `web`'s**. That is deliberate: `pugixml` is pulled by `FetchContent` - (`CMakeLists.txt:2074`, `GIT_TAG` pinned to `PUGIXML_VERSION`), not by a package manager, so + (`CMakeLists.txt:2206`, `GIT_TAG` pinned to `PUGIXML_VERSION`), not by a package manager, so there is nothing to install — and keeping the package set identical means a red/green difference between the two legs can only be attributed to the switch itself. - **All four gates are load-bearing here.** Gate ② is `pugixml integrated` (the FetchContent @@ -520,7 +520,7 @@ table lost its `MinGW + yyjson` row rather than gaining a row here). compiles this header with **libc++**, whose `double` formatting is not libstdc++'s. The byte-identical write-back assertion is precisely the kind that differs across those two. - **`flags` is `web` plus one switch, and the dep list is byte-identical to `web`'s on all - three legs.** `yyjson` is pulled by `FetchContent` (`CMakeLists.txt:2134`, `GIT_TAG` pinned + three legs.** `yyjson` is pulled by `FetchContent` (`CMakeLists.txt:2266`, `GIT_TAG` pinned to `YYJSON_VERSION`) and built as an OBJECT library, not found by a package manager, so there is nothing to install — and keeping the package set identical means a red/green difference can only be attributed to the switch. diff --git a/doc/expand-guide.md b/doc/expand-guide.md index 69f2375e..d803e8be 100644 --- a/doc/expand-guide.md +++ b/doc/expand-guide.md @@ -95,18 +95,18 @@ cmake -S . -B build -DUVCPP_BUILD_EXPAND=ON | `-DUVCPP_BUILD_EXPAND=ON` | `UVCPP_ENABLE_MEMORY_POOL=1` | | `-DUVCPP_BUILD_EXPAND=OFF`(默认) | `UVCPP_ENABLE_MEMORY_POOL=0` | -选项到宏的映射在 `CMakeLists.txt:1909-1915` 一处完成。用预编译包时**什么都不用传** —— +选项到宏的映射在 `CMakeLists.txt:2041-2047` 一处完成。用预编译包时**什么都不用传** —— 包里的 `include/uvcpp/uvcpp_config.h` 就是那次构建的值,自己再传一个冲突的值是硬 `#error`。 关掉时 `src/expand/` 整目录被 `list(FILTER ... EXCLUDE REGEX "src/expand/")` 排除 -(`CMakeLists.txt:2334-2343`)。于是"关掉之后包含它"的表现取决于**你的头是怎么来的** +(`CMakeLists.txt:2466-2475`)。于是"关掉之后包含它"的表现取决于**你的头是怎么来的** —— 而能不能编过,只由"那个头在不在你的 include 路径里"决定: | 你怎么构建 | `#include ` 的结果 | |---|---| | 源码树自己构建(没开开关) | **编得过,链接失败** —— 头还在 `src/expand/` 下,且四个头里**没有任何一个用宏守卫自己**(唯一提到这个宏的地方是 `src/expand/uvcpp_page_heap.h:8` 的一句注释),没有 `#error` 兜底;但符号一个都没编进库 | | 用**官方预编译包** | **什么都不用传,直接用** —— 六条发布腿的十处 configure 都传 `-DUVCPP_BUILD_EXPAND=ON`(`release.yml` 里十处都有),包里那个 `uvcpp_config.h` 的 `UVCPP_ENABLE_MEMORY_POOL` 是 **1**,`include/expand/` 那四个头也在。上面那句"用预编译包什么都不用传"在这里是**字面意思** | -| 自己 `cmake --install` 到一个前缀(没开开关) | **编译期就报找不到头** —— 这条路按开关装头(`CMakeLists.txt:3624-3627`),`include/expand/` 不会被装出去 | +| 自己 `cmake --install` 到一个前缀(没开开关) | **编译期就报找不到头** —— 这条路按开关装头(`CMakeLists.txt:3756-3759`),`include/expand/` 不会被装出去 | | 自己跑 `package_release.py` 打的包(没开开关) | 与第一行同 —— **编得过、链接失败**。它拷头是按 `MODULES` 逐个目录拷的(`tests/tools/package_release.py`),**不看这个开关**,所以 `include/expand/` 照样在包里;但包里那个宏是 0、库里也没有那些符号 | > **别把第三、四行记成一回事**:`cmake --install` 与 `package_release.py` 是两套独立的 diff --git a/doc/grpc-guide.md b/doc/grpc-guide.md index 13eb2746..d7bc9ea8 100644 --- a/doc/grpc-guide.md +++ b/doc/grpc-guide.md @@ -10,16 +10,16 @@ 这个分法不是洁癖,是**依赖事实**:编解码那半的每一个参数都是 `std::string` / `uint32_t` (`src/grpc/uvcpp_grpc.h:122-216`),而服务端那半的每个参数都是 web 层的类型 (`src/grpc/uvcpp_grpc_server.h:116-132`)。所以关掉 web 模块时前者照编照装、后者 -**从构建与安装里都摘掉**(`CMakeLists.txt:2400-2402`、`CMakeLists.txt:3648-3653`)—— +**从构建与安装里都摘掉**(`CMakeLists.txt:2532-2534`、`CMakeLists.txt:3780-3785`)—— 装在 `include/grpc/` 下,而不是 `include/web/` 下。 - 打开方式:**没有开关**。编解码那半任何配置下都在;服务端那半跟着 `UVCPP_BUILD_WEB` - 走(`CMakeLists.txt:2400-2400`)。加一个 `UVCPP_ENABLE_GRPC` 只会多一个能与 + 走(`CMakeLists.txt:2532-2532`)。加一个 `UVCPP_ENABLE_GRPC` 只会多一个能与 `UVCPP_BUILD_WEB` 打架的旋钮,而两半的依赖是死的、不需要调用方表态。 - 包含方式:``、``。 - 依赖:帧与 varint 那半**只依赖 `` 与 `libuv` 的错误码**( `src/grpc/uvcpp_grpc.h:42`);服务端那半额外依赖 `web/uvcpp_http_common.h` - 与 `uvcpp_http_server::send_trailers()`(`src/web/uvcpp_http_server.h:848-848`)。 + 与 `uvcpp_http_server::send_trailers()`(`src/web/uvcpp_http_server.h:868-868`)。 > 本页讲**怎么用**,以及**为什么这么切**。与本页配对的两份用例是 > `tests/functional/grpc_codec_func.cpp`(编解码,任何配置下都跑)与 @@ -62,7 +62,7 @@ HEADERS 尾随头 grpc-status: 0(自带 END_STREAM) Trailers-Only 的失败应答读成"200,body 是空的"。 - **`grpc-status` 按规范必须走尾随头**,不走首部(gRPC 的 `PROTOCOL-HTTP2.md` 定在 那里;RFC 9113 §8.1 提供了"首部之后还能有一个头块"这条机制)。本库为此在 1.6.9 补了 - `uvcpp_http_server::send_trailers()`(`src/web/uvcpp_http_server.h:848-848`)。 + `uvcpp_http_server::send_trailers()`(`src/web/uvcpp_http_server.h:868-868`)。 - 失败应答可以**只有第三段**(没有 DATA)—— gRPC 里叫 **Trailers-Only**。本模块的 两条失败路径都是这个形状(`src/grpc/uvcpp_grpc_server.cpp:117-133`)。 diff --git a/doc/http2-guide.md b/doc/http2-guide.md index ab44d4bc..c34a6ac6 100644 --- a/doc/http2-guide.md +++ b/doc/http2-guide.md @@ -18,7 +18,7 @@ (`src/http2/uvcpp_h2_session.h:70`)。 - 包含方式:``、``、 ``。私有的 `` **不安装** - (`CMakeLists.txt:3738-3738`)。 + (`CMakeLists.txt:3870-3870`)。 > 本页讲**怎么用**。它与 [HTTP/2 支持现状](./http2-status.md) 分工:那篇讲 > **实现进度、写死的折衷、已知缺口**,本页不重复那些,需要时直接链过去。 @@ -72,12 +72,12 @@ int drain(std::string& out, size_t max_bytes = 0); // src/http2/u ## 2. 编译期条件 `UVCPP_NGHTTP2_ENABLE` **在任何构建里都有定义**,只是值不同:ON ⇒ `1`,OFF ⇒ `0` -(`CMakeLists.txt:2850-2850`)。三个公开头把**全部内容**包在 `#if UVCPP_NGHTTP2_ENABLE` 里 -(`src/http2/uvcpp_h2_common.h:19`、`src/http2/uvcpp_h2_session.h:33`、`src/http2/uvcpp_h2_connection.h:27`)。 +(`CMakeLists.txt:2982-2982`)。三个公开头把**全部内容**包在 `#if UVCPP_NGHTTP2_ENABLE` 里 +(`src/http2/uvcpp_h2_common.h:19`、`src/http2/uvcpp_h2_session.h:33`、`src/http2/uvcpp_h2_connection.h:29`)。 为 0 时:头**还在**(源码树里能 include、也编得过),但里面**一个类型都不声明** —— 写 `uvcpp_h2_session s(true);` 会"未定义类型"。安装出来的包里则**根本没有这几个头** -(`CMakeLists.txt:3738-3738` 只在开关 ON 时装)。 +(`CMakeLists.txt:3870-3870` 只在开关 ON 时装)。 所以使用者的写法是把自己的那段包起来: @@ -152,22 +152,22 @@ void doc_h2_memory_pair() { ```cpp // doc-snippet: fragment — 对着头文件抄的接口清单,不是完整翻译单元 -uvcpp_h2_connection(uvcpp_tcp_client* client, bool server_side); // src/http2/uvcpp_h2_connection.h:58 +uvcpp_h2_connection(uvcpp_tcp_client* client, bool server_side); // src/http2/uvcpp_h2_connection.h:60 int start(const uvcpp_h2_session::callbacks& h2_cbs, - const callbacks& conn_cbs); // src/http2/uvcpp_h2_connection.h:70 + const callbacks& conn_cbs); // src/http2/uvcpp_h2_connection.h:72 int send_response(int32_t stream_id, const uvcpp_http_response& resp, - bool omit_body = false); // src/http2/uvcpp_h2_connection.h:100 -int send_status(int32_t stream_id, int status, const std::string& body); // :104 -int send_headers(int32_t stream_id, const uvcpp_http_response& resp); // :109 + bool omit_body = false); // src/http2/uvcpp_h2_connection.h:102 +int send_status(int32_t stream_id, int status, const std::string& body); // :106 +int send_headers(int32_t stream_id, const uvcpp_http_response& resp); // :111 int send_data(int32_t stream_id, const char* data, size_t len, - bool end_stream, std::function done); // :127-127 -int flush(); // :158-158 -int begin_goaway(); // :171-171 -void shutdown(); // :174-174 -void close_now(); // :177-177 + bool end_stream, std::function done); // :129-129 +int flush(); // :160-160 +int begin_goaway(); // :173-173 +void shutdown(); // :176-176 +void close_now(); // :179-179 ``` -它**不拥有** `uvcpp_tcp_client`(`src/http2/uvcpp_h2_connection.h:34`), +它**不拥有** `uvcpp_tcp_client`(`src/http2/uvcpp_h2_connection.h:36`), 但**拥有自己的 `uvcpp_h2_session`** —— 会话是在构造函数里 `new` 出来的 (`src/http2/uvcpp_h2_connection.cpp:56`),由 `shared_ptr` 回收。 **会话可以脱离 connection 单独用**([§3](#3-会话层的最小用法) 就是), @@ -178,27 +178,27 @@ void close_now(); // :17 ```cpp // doc-snippet: fragment — 结构体定义摘录,不是完整翻译单元 struct callbacks { - std::function on_disconnect; // src/http2/uvcpp_h2_connection.h:46 + std::function on_disconnect; // src/http2/uvcpp_h2_connection.h:48 }; ``` ### 建它的四条硬要求 1. **socket 必须已经连上。** connection 在 `start()` 里自己装读回调 - (`src/http2/uvcpp_h2_connection.cpp:115-115` 用 `read_start_events`), + (`src/http2/uvcpp_h2_connection.cpp:124-124` 用 `read_start_events`), 而没连上的 client 上这个调用返回 `UV_ENOTCONN` —— **而且那个失败是静默的**, 没人会再 arm 一次。库内正解是等到 connect 成功回调里才 `new` (`src/web/uvcpp_http_client.cpp:329-329`)。 2. **ALPN 必须已经协商成 `h2`。** connection 的构造函数**不校验**这一点 (`src/http2/uvcpp_h2_connection.cpp:56` 只存指针),但头文件的参数说明要求它 - (`src/http2/uvcpp_h2_connection.h:54`)。谁建谁自己判: + (`src/http2/uvcpp_h2_connection.h:56`)。谁建谁自己判: `client->is_tls() && client->tls_alpn_selected() == "h2"` - (照 `src/web/uvcpp_http_server.cpp:1035-1035`)。 + (照 `src/web/uvcpp_http_server.cpp:1089-1089`)。 3. **`on_disconnect` 里必须销毁这个对象。** 头文件写得很直白: "回调返回后**不要**再碰本对象 —— 持有者应当在这里把它销毁" - (`src/http2/uvcpp_h2_connection.h:46-51`)。 + (`src/http2/uvcpp_h2_connection.h:48-53`)。 4. **`start()` 会把 `on_fatal` 换成自己的包装**(就地 `shutdown()`, - `src/http2/uvcpp_h2_connection.cpp:96-96`)—— 你装的那个仍会被调用,但不是唯一的 + `src/http2/uvcpp_h2_connection.cpp:98-98`)—— 你装的那个仍会被调用,但不是唯一的 收尾动作。 TLS 与 ALPN 全是 `uvcpp_tcp_client` 内部的事,这一层只读一个字符串 @@ -208,7 +208,7 @@ TLS 与 ALPN 全是 `uvcpp_tcp_client` 内部的事,这一层只读一个字 ### 唯一的那个连接级回调 `on_disconnect` 在三种情况下触发:对端关了、读错了、我们自己关完了 -(`src/http2/uvcpp_h2_connection.cpp:308-308`、`:493-493`)。它**排在框架自己的关闭回调之前**, +(`src/http2/uvcpp_h2_connection.cpp:497-497`、`src/http2/uvcpp_h2_connection.cpp:692-692`)。它**排在框架自己的关闭回调之前**, 所以那是你最后一次能安全碰这条连接的机会。 --- @@ -217,16 +217,16 @@ TLS 与 ALPN 全是 `uvcpp_tcp_client` 内部的事,这一层只读一个字 **能用 `uvcpp_h2_connection` 上的 `send_*` 就别用 `session().submit_*`。** 那四个 `send_*` 是"`submit_*` + `flush()`"的合并 —— 忘了 `flush()` 就是 -"响应提交了但一个字节都没发"这种最难查的静默失败(`src/http2/uvcpp_h2_connection.h:74`)。 +"响应提交了但一个字节都没发"这种最难查的静默失败(`src/http2/uvcpp_h2_connection.h:76`)。 -库内那份接好的实现(`src/web/uvcpp_http_server.cpp:3070-3070` 起)的调用序列: +库内那份接好的实现(`src/web/uvcpp_http_server.cpp:3197-3197` 起)的调用序列: -1. 分流点判 ALPN,是 h2 就走另一条路(`src/web/uvcpp_http_server.cpp:1035-1035`); -2. `new uvcpp_h2_connection(client, /*server_side=*/true)`(`src/web/uvcpp_http_server.cpp:3070-3070`); -3. 装 `uvcpp_h2_session::callbacks`(`src/web/uvcpp_http_server.cpp:3075-3075`)与 `uvcpp_h2_connection::callbacks`(`src/web/uvcpp_http_server.cpp:3158-3158`); -4. 挂框架自己的关闭回调 —— **最终 `delete` 在那里**(`src/web/uvcpp_http_server.cpp:3165-3165`); -5. `h2->start(h2c, cc)`(`src/web/uvcpp_http_server.cpp:3165-3165`);失败就 `h2->close_now()`(`src/web/uvcpp_http_server.cpp:3168-3168`); -6. 业务处理完之后 `h2->send_response(stream_id, resp, omit_body)`(`src/web/uvcpp_http_server.cpp:3249-3249` 起)。 +1. 分流点判 ALPN,是 h2 就走另一条路(`src/web/uvcpp_http_server.cpp:1089-1089`); +2. `new uvcpp_h2_connection(client, /*server_side=*/true)`(`src/web/uvcpp_http_server.cpp:3197-3197`); +3. 装 `uvcpp_h2_session::callbacks`(`src/web/uvcpp_http_server.cpp:3202-3202`)与 `uvcpp_h2_connection::callbacks`(`src/web/uvcpp_http_server.cpp:3285-3285`); +4. 挂框架自己的关闭回调 —— **最终 `delete` 在那里**(`src/web/uvcpp_http_server.cpp:3292-3292`); +5. `h2->start(h2c, cc)`(`src/web/uvcpp_http_server.cpp:3292-3292`);失败就 `h2->close_now()`(`src/web/uvcpp_http_server.cpp:3295-3295`); +6. 业务处理完之后 `h2->send_response(stream_id, resp, omit_body)`(`src/web/uvcpp_http_server.cpp:3376-3376` 起)。 一个能编的最小响应侧写法: @@ -267,9 +267,9 @@ done)` → 最后一块 `end_stream = true`。三处要点: - **提交过 `end_stream` 之后这条流不再接受新的 `submit_data`**,再发就是协议违例 (`src/http2/uvcpp_h2_session.h:342-342`); - **每一块的 `done` 必须恰好跑一次**,流中途被 RST 或连接断了也会跑,参数是 - `UV_ECANCELED`(`src/http2/uvcpp_h2_connection.h:153-156`); + `UV_ECANCELED`(`src/http2/uvcpp_h2_connection.h:155-158`); - **拆传输的正确顺序**是 `take_cancelled_dones(out)` → 销毁对象 → 在**自己的上下文 - 已经拆干净之后**逐个跑那些 `done`(`src/http2/uvcpp_h2_connection.h:179-191`)。 + 已经拆干净之后**逐个跑那些 `done`(`src/http2/uvcpp_h2_connection.h:181-193`)。 它只取走、不跑,理由写在头里。 --- @@ -320,7 +320,7 @@ void doc_h2_client_submit(uvcpp::uvcpp_h2_connection* conn) { → `h2_->start(sc, cc)`(`src/web/uvcpp_http_client.cpp:2091-2091`)→ `send()` 分流到 `send_h2`(`src/web/uvcpp_http_client.cpp:489-489`)。 **`set_http2_enabled` 默认是关的**(`src/web/uvcpp_http_client.h:696-696`、 -`src/web/uvcpp_http_server.h:357-357`)—— 低层的两条线都要显式打开, +`src/web/uvcpp_http_server.h:364-364`)—— 低层的两条线都要显式打开, 只有 `webapp/` 框架层是零配置自动协商。 --- @@ -343,7 +343,7 @@ void doc_h2_client_submit(uvcpp::uvcpp_h2_connection* conn) { `on_request_end` 的触发条件是**「这条流的 END_STREAM 到了」**,不是"有请求体才算" (`src/http2/uvcpp_h2_session.cpp:597-597`)。HEADERS 自带 END_STREAM 的请求(也就是 绝大多数 GET)**也会触发**,而且是紧接着 `on_request` 同步来的 —— 库内自己就依赖 -这一点:`src/web/uvcpp_http_server.cpp:3098-3099` 明说那里**不能** `erase` 流状态, +这一点:`src/web/uvcpp_http_server.cpp:3225-3226` 明说那里**不能** `erase` 流状态, 无 body 的请求这两下是背靠背的,擦掉之后那条请求就没人派发了。 **二、客户端交付响应只能放 `on_response_end`。** 带 body 的响应里 `on_response` 的 @@ -383,15 +383,15 @@ void doc_h2_client_submit(uvcpp::uvcpp_h2_connection* conn) { | 项 | 值 | 位置 | |---|---|---| -| 单个待发头部块 | 64 KiB(`H2_MAX_SEND_HEADER_BLOCK`) | `src/http2/uvcpp_h2_common.h:57`、设置点 `src/http2/uvcpp_h2_session.cpp:929-929`、自查 `src/http2/uvcpp_h2_session.cpp:1250-1250` | +| 单个待发头部块 | 64 KiB(`H2_MAX_SEND_HEADER_BLOCK`) | `src/http2/uvcpp_h2_common.h:57`、设置点 `src/http2/uvcpp_h2_session.cpp:929-929`、自查 `src/http2/uvcpp_h2_session.cpp:1256-1256` | | 单流 body | 64 MiB(`H2_DEFAULT_MAX_BODY_BYTES`)→ RST | `src/http2/uvcpp_h2_common.h:32`、`src/http2/uvcpp_h2_session.cpp:684-684` | -| 单流**待发**队列 | 4 MiB(`H2_DEFAULT_MAX_OUT_STREAM_BYTES`)→ `submit_data` 同步返 `UV_ENOBUFS` | `src/http2/uvcpp_h2_common.h:79`、`src/http2/uvcpp_h2_session.cpp:1360-1360` | +| 单流**待发**队列 | 4 MiB(`H2_DEFAULT_MAX_OUT_STREAM_BYTES`)→ `submit_data` 同步返 `UV_ENOBUFS` | `src/http2/uvcpp_h2_common.h:79`、`src/http2/uvcpp_h2_session.cpp:1366-1366` | | `content-length` 荒谬值 | `> 1<<40` 判非法 | `src/http2/uvcpp_h2_session.cpp:441-441` | | 控制帧令牌桶 | burst 64、补充 32 个/秒 | `src/http2/uvcpp_h2_session.cpp:75-76`、`control_frame_ok()` `:217-217` | | `:scheme` 与实际传输层一致 | TLS 只接受 `https`、明文只接受 `http`,不符即 RST(两个都收等于给混淆代理开门,RFC 9113 §8.1.1) | `src/http2/uvcpp_h2_session.cpp:384-387` | **没有闲置超时**(`src/http2/` 里 grep `idle|timeout|keepalive` 零命中)。 -`src/web/uvcpp_http_server.h:1454-1457` 提到的那个 idle sweep 属于 **webapp 层** +`src/web/uvcpp_http_server.h:1481-1484` 提到的那个 idle sweep 属于 **webapp 层** (默认 60 s),既不是 h1 服务器自带的,也不覆盖 h2 连接。 对端的观测口:`peer_max_concurrent_streams()`(`src/http2/uvcpp_h2_session.h:447-447`)、 @@ -454,7 +454,7 @@ if (rv < 0) { // src/http2/uvcpp_h2_session.cpp:988-988 **致命只通知一次**(`fatal_reported`),而且致命之后**不再进 nghttp2**: `recv()` 直接回上次那个错误(`src/http2/uvcpp_h2_session.cpp:977-977`)。 -`on_fatal` 有三个触发点(`src/http2/uvcpp_h2_session.cpp:994-994`、`src/http2/uvcpp_h2_session.cpp:1004-1004`、`src/http2/uvcpp_h2_session.cpp:1017-1017`): +`on_fatal` 有三个触发点(`src/http2/uvcpp_h2_session.cpp:1000-1000`、`src/http2/uvcpp_h2_session.cpp:1010-1010`、`src/http2/uvcpp_h2_session.cpp:1023-1023`): - `nghttp2_session_mem_recv2` 返回负值; - 输入**没吃完**(自造一个 `-1`); @@ -487,7 +487,7 @@ if (rv < 0) { // src/http2/uvcpp_h2_session.cpp:988-988 (`src/web/uvcpp_http_client.cpp:329-329`、`tests/functional/web_ssl_h2_server_func.cpp:410-410`)。 **ALPN 要自己确认。** 构造函数不校验 `tls_alpn_selected() == "h2"`,但头文件的参数 -说明要求它已经协商好(`src/http2/uvcpp_h2_connection.h:54`)。谁建谁判。 +说明要求它已经协商好(`src/http2/uvcpp_h2_connection.h:56`)。谁建谁判。 **`on_disconnect` 里必须销毁 connection。** 见 [§4](#4-传输层)。 @@ -496,7 +496,7 @@ if (rv < 0) { // src/http2/uvcpp_h2_session.cpp:988-988 `nghttp2_stream`(`src/http2/uvcpp_h2_session.h:290-290`)。用 `in_nghttp2()` 判自己是不是 在回调里;推迟到 `recv()` 返回之后再冲即可,连接层本来就在返回之后冲一次。 **注意 `flush()` 在回调里调用是安全的** —— 它自己会推迟,排队的字节一个都不会丢 -(`src/http2/uvcpp_h2_connection.h:158-162`)。 +(`src/http2/uvcpp_h2_connection.h:160-164`)。 **`recv()` 的返回值不能在连接已死之后用来判据。** 回调可能把宿主整条析构掉, 那时 `this` 已经没了。所以调用方进来之前要先本地持一份 `shared_ptr` @@ -512,7 +512,7 @@ if (rv < 0) { // src/http2/uvcpp_h2_session.cpp:988-988 **`run_completed()` 只在没有写在飞的时候调**,而且 `done` 跑起来之后**一个字都不能 写成员** —— `done` 跑的是用户代码,它可能再补一笔写 -(`src/http2/uvcpp_h2_connection.h:230-230`)。 +(`src/http2/uvcpp_h2_connection.h:245-245`)。 **`content-length` 校验只在服务端请求方向做。** 客户端侧的响应头只挡连接专属头, 不校验 `content-length`(`src/http2/uvcpp_h2_session.cpp:517-517`)。 diff --git a/doc/http2-status.md b/doc/http2-status.md index 464b4147..51235dc4 100644 --- a/doc/http2-status.md +++ b/doc/http2-status.md @@ -39,7 +39,7 @@ NGHTTP2_ERR_FRAME_SIZE_ERROR`,而那个错误码是 `is_non_fatal` 的 —— 它在上层 被处理成"丢掉整帧、关掉这条流、继续跑",既不通知我们、也不发 RST_STREAM。 本层在 `submit_*` 里按同一个公式先算一遍,换成同步的 `UV_EMSGSIZE` - (`src/http2/uvcpp_h2_session.cpp:1244-1250`)。 + (`src/http2/uvcpp_h2_session.cpp:1250-1256`)。 - **收到对端 GOAWAY 之后不再接受新流。** `on_frame_recv` 记下 `last_stream_id` 与 错误码,`submit_request` 用 `nghttp2_session_check_request_allowed()` 提前拦, 同步返回 `UV_ENOTCONN`;`peer_goaway_received()` 等三个取值函数把它暴露出去。 @@ -74,7 +74,7 @@ ### 1.3 三个接入面 - **低层库**:`uvcpp_http_client::set_http2_enabled`(`src/web/uvcpp_http_client.h:444-444`) - 与 `uvcpp_http_server::set_http2_enabled`(`src/web/uvcpp_http_server.h:355-355`), + 与 `uvcpp_http_server::set_http2_enabled`(`src/web/uvcpp_http_server.h:362-362`), **都默认关**。 - **框架(webapp)**:零配置自动协商。ALPN 名单里 `h2` 在前 (`src/webapp/uvcpp_web_app.cpp:587-587`,`kDefaultAlpn` 的定义),用户只能关掉它 @@ -207,7 +207,7 @@ | 缺陷 | 症状 | 修法 | |---|---|---| | 服务端停机**不道别** | 停机时直接关连接,对端只看到连接断了,分不清"服务端在收摊"和"网络挂了" | 新增 `uvcpp_http_server::begin_h2_goaway()` 与 `uvcpp_h2_connection::begin_goaway()`;webapp 停机的第 0 拍只发 GOAWAY,**隔一拍**才关连接 —— 挤在同一拍里对端拿到的仍然是"断了" | -| `on_read` 里结算出来的 `done` **没人跑** | 对端一个 `RST_STREAM` 打过来,会话会把那条流还没上线的块整体作废并塞进 `completed` —— 而一个字节都不用回,`flush()` 起不了写,`on_write_done` 就不来,那批 `done` 永远躺在队列里;等它的人(框架流式响应的 `pending_bytes_`)永远等不到 ⇒ 那条流的上下文永远不释放,停机时宽限期白等满 | `on_read()` 收尾补一次 `run_completed()`(`src/http2/uvcpp_h2_connection.cpp:157-168`) | +| `on_read` 里结算出来的 `done` **没人跑** | 对端一个 `RST_STREAM` 打过来,会话会把那条流还没上线的块整体作废并塞进 `completed` —— 而一个字节都不用回,`flush()` 起不了写,`on_write_done` 就不来,那批 `done` 永远躺在队列里;等它的人(框架流式响应的 `pending_bytes_`)永远等不到 ⇒ 那条流的上下文永远不释放,停机时宽限期白等满 | `on_read()` 收尾补一次 `run_completed()`(`src/http2/uvcpp_h2_connection.cpp:328-344`) | | 拆连接时**丢掉**在飞的 `done` | 同一条路的另一半:连接被整个丢掉(对端 `close()`、不发 RST)时 `remove_ctx` 直接 `delete` 掉 h2 层,队列里那些块一声不吭 —— 与 h1 那边"队列里的写一律以 `UV_ECANCELED` 唤醒"的既定契约不一致 | 新增 `take_cancelled_dones()`:会话层 `cancel_pending_out()` 把待发块整体作废并**取走**,由 `remove_ctx` 在 `contexts_.erase(it)` **之后**才逐个跑 —— 跑早了 `write_stream()` 会掉进 h1 分支,把收尾时补的那笔写挂到一条根本不是 h1 的连接上(`stream_id` 被静默丢掉) | | `run_completed()` 里两处 **use-after-free** | 令牌已死那一支还去写 `in_dones_ = false`;`on_write_done` 里 `flush()` 可能同步走到 `finish_close()` → `c->close(cb)` → `notify_disconnect()`,而持有者的契约正是"在这里销毁本对象" ⇒ 之后每一句都在往释放过的内存上写 | 令牌在每一句之前重新问一次;令牌真死了**连收尾都不做**(要收尾的对象已经不存在,没什么可收的) | | 服务端析构**漏掉** h2 层 | `~uvcpp_http_server()` 只 `delete parser`,而 h2 层是连接上下文 `new` 出来的、没有任何别的表登记它 ⇒ 每条还活着的 h2 连接漏一个 nghttp2 会话和它的缓冲区 | 析构里一并 `delete`。走得到这里的只有"客户端先于服务端被释放"那条路:`close_all_clients()` 在句柄已关完时走 `release_client()`,只 `delete`、一个回调都不发 ⇒ `remove_ctx` 从没跑过 | @@ -314,7 +314,7 @@ NONE"的实现也能全绿;**m3** h1 不在头完成时记状态码 ⇒ `web_h ### 4.3 盘查时判为缺陷、**核下来不是**的(免得下次再盘一遍) - **"本层可能提交超过对端 `SETTINGS_MAX_CONCURRENT_STREAMS` 的并发流"—— 不成立, - 此处更正。** `peer_max_concurrent_streams()`(`src/http2/uvcpp_h2_session.cpp:1733-1733`)确实 + 此处更正。** `peer_max_concurrent_streams()`(`src/http2/uvcpp_h2_session.cpp:1739-1739`)确实 零生产调用方,但 nghttp2 自己就按这个上限**排队**而不是拒绝:超出的请求 HEADERS 留在 `ob_syn`(`nghttp2:nghttp2_session.c:2315,2346` 上的 `session_is_outgoing_concurrent_streams_max()` 闸门),流一关 @@ -377,7 +377,7 @@ ctest --test-dir build-h2 -C Release --timeout 60 - `copy_test_dlls` 是 `add_custom_target(... ALL ...)`,命令全是 `${CMAKE_COMMAND} -E copy_if_different`,**一个 `pwsh` 都不沾**,构建日志里 "Copy uvcpp/libuv DLLs into test folders" 那行就是它。它确实会跑。真正 - `0xc0000135` 满屏的根因是这张目标**曾经没带 `ALL`**(见 `CMakeLists.txt:4093-4093` + `0xc0000135` 满屏的根因是这张目标**曾经没带 `ALL`**(见 `CMakeLists.txt:4225-4225` 的注释),与 `pwsh` 无关。 - 日志里那句 `'pwsh.exe' 不是内部或外部命令` 来自 **vcpkg 的 `scripts/buildsystems/msbuild/vcpkg.targets`**(`applocal.ps1`),而且它自己 diff --git a/doc/http3-guide.md b/doc/http3-guide.md index a738b9d1..3b5ee586 100644 --- a/doc/http3-guide.md +++ b/doc/http3-guide.md @@ -30,12 +30,12 @@ `uvcpp_http_client` / `uvcpp_http_server` 上,web 关掉时它没有使用者。 - 包含方式:``、``。 私有的 `` 与 `` **都不安装** - (`CMakeLists.txt:3779-3779`)—— 理由见 [§7](#7-典型坑) 第一条。 + (`CMakeLists.txt:3911-3911`)—— 理由见 [§7](#7-典型坑) 第一条。 - 两个公开头整段套在 `#if UVCPP_HTTP3_ENABLE` 里,web 层那边新加的 `listen_quic()` / `set_http3_enabled()` 也是,所以**不开关就一个名字都看不到**。 这与 `quic/`、`web/`、`ssl/`、`http2/`、`wsdl/` 同档。 - 开关与依赖:nghttp3 走 FetchContent(`NGHTTP3_VERSION`,`CMakeLists.txt:371-371`), - 静态链入 `nghttp3_static`(`CMakeLists.txt:3335-3335`)—— 详见 + 静态链入 `nghttp3_static`(`CMakeLists.txt:3467-3467`)—— 详见 [§5](#5-cmake-接线与那条-check-撞名的坑)。 > 本指南里的签名、默认值、行为都对着当前源码核过。凡是"这一版没做"的地方都明确 @@ -286,7 +286,7 @@ void connect_over_http3(uvcpp_http_client& cli, int udp_port) { } ``` -- `uvcpp_http_server::listen_quic()` 在 `src/web/uvcpp_http_server.h:270`, +- `uvcpp_http_server::listen_quic()` 在 `src/web/uvcpp_http_server.h:277-277`, 客户端那一侧是 `set_http3_enabled()`(`src/web/uvcpp_http_client.h:515-515`)。 **整个 h3 公开面都套在 `#if UVCPP_HTTP3_ENABLE` 里** —— 没编进来时它不存在, 这是**编译期**的"没有",不是运行时返回错误。 @@ -378,8 +378,8 @@ void connect_over_http3(uvcpp_http_client& cli, int udp_port) { 在 cache 那一层长得一模一样。配置成功的标志是这行 STATUS: ``` - nghttp3 integrated (tag=v1.18.0, static) # CMakeLists.txt:1677-1677 - Including http3 module in build (nghttp3 v1.18.0) # CMakeLists.txt:2472-2472 + nghttp3 integrated (tag=v1.18.0, static) # CMakeLists.txt:1809-1809 + Including http3 module in build (nghttp3 v1.18.0) # CMakeLists.txt:2604-2604 ``` 2. **依赖用 `FetchContent_Declare` + `Populate` + `add_subdirectory(... EXCLUDE_FROM_ALL)`, @@ -396,21 +396,31 @@ void connect_over_http3(uvcpp_http_client& cli, int udp_port) { 推论也一样:`-DFETCHCONTENT_SOURCE_DIR_NGHTTP3=<本地检出>` 之后改了那份检出, 要删掉 `build*/_deps/uvcpp-nghttp3-src/` 再 configure。 + **同一个副本上还有一组控制流校验补丁(`1.13.2-dev` 起)**,因为 nghttp3 1.18 + (1.19.0 与 master 至今也未改)在五处与 RFC 9114 不一致:同一个 SETTINGS 标识 + 出现两次被静默接受;控制流上的 `CANCEL_PUSH` 回 `H3_FRAME_UNEXPECTED` 而不是 + `H3_ID_ERROR`;`MAX_PUSH_ID` 下降回 `H3_FRAME_ERROR` 而不是 `H3_ID_ERROR`; + `MAX_PUSH_ID` 的 varint 之后多余字节被忽略;控制流帧长没有上限(声明 1 GiB 的帧 + 照单全收)。补丁只改构建目录副本,`NGHTTP3_VERSION` 仍指向上游 tag,nghttp3 的 + 公开头与 ABI 不变;每处替换都有定位断言,上游改行时配置期报错而不是静默空转。 + `web_app_h3_http_func` 对五类各有一条真 QUIC 回归(期望关闭码 + 0x0109/0x0108/0x0108/0x0106/0x0107),h3spec 0.1.15 全量 86 例 0 失败、1 pending。 + 4. **后置断言两条**:`if(NOT TARGET nghttp3_static)` FATAL - (`CMakeLists.txt:1739-1739`;**裸目标名,没有 ALIAS**,别去猜 + (`CMakeLists.txt:1871-1871`;**裸目标名,没有 ALIAS**,别去猜 `nghttp3::nghttp3_static`),以及把 `POSITION_INDEPENDENT_CODE` 读回来断言 (`CMakeLists.txt:1600-1600`)—— 后者是"Linux 上 `libuvcpp.so` 链接失败"这件事的成因。 5. **三处编译定义同步**:`cmake/uvcpp_config.h.in` 的 `UVCPP_HTTP3_ENABLE` 段、 目录级 `add_compile_definitions`、PUBLIC `target_compile_definitions`, - 外加 `_uvcpp_literal01(UVCPP_HTTP3_ENABLE UVCPP_ENABLE_HTTP3)`(`CMakeLists.txt:2852-2852`)。 + 外加 `_uvcpp_literal01(UVCPP_HTTP3_ENABLE UVCPP_ENABLE_HTTP3)`(`CMakeLists.txt:2984-2984`)。 四处不一致会以 `#error` 或静默的 ABI 错配收场,`check_config_contract.py` 盯着 其中一个方向。 -6. **链接是 PRIVATE**(`CMakeLists.txt:3335-3335` 的 `$`): +6. **链接是 PRIVATE**(`CMakeLists.txt:3467-3467` 的 `$`): nghttp3 的头路径不传播给使用者,所以**功能测试不能** `#include `;想知道版本就用 `uvcpp_h3_connection::nghttp3_version()` - (`src/http3/uvcpp_h3_connection.h:480-480`),它经公开头调用、链接期解析。 + (`src/http3/uvcpp_h3_connection.h:490-490`),它经公开头调用、链接期解析。 7. **本机可复现**:nghttp3 也可以用 `-DFETCHCONTENT_SOURCE_DIR_NGHTTP3=<一份已下好的 nghttp3 源码>` 指过去绕开下载 @@ -422,7 +432,7 @@ void connect_over_http3(uvcpp_http_client& cli, int udp_port) { 模块",所以 §3.3 那条明明只用 web 层 API 的片段也列了 `` —— 不列的话它会**被编**,而它调的 `set_http3_enabled()` / `listen_quic()` 整段在 `#if UVCPP_HTTP3_ENABLE` 里 - (`src/web/uvcpp_http_client.h:515-515`、`uvcpp_http_server.h:220`),于是报的是"未声明的 + (`src/web/uvcpp_http_client.h:515-515`、`uvcpp_http_server.h:227`),于是报的是"未声明的 成员":那是**假红**(文档没腐烂,是那个包没编 h3)。 登记之后,`config-contract` job 手里那个包会把这三条判成 `[跳·默认关]` 而不是 `[跳]`,**退出码不会抬到 3**。两个宏(`UVCPP_QUIC_ENABLE`、`UVCPP_HTTP3_ENABLE`) @@ -473,7 +483,7 @@ h1 写泵、TCP 的 ALPN 列表与分支 —— **全部不改**。唯一的例 **(c)往共享结构里加了什么:服务端零。** h3 用**另一张表** (`std::map quic_ctxs_`, -`src/web/uvcpp_http_server.h:1750-1750`),只在 QUIC 回调里碰;`conn_ctx` **不加任何 +`src/web/uvcpp_http_server.h:1777-1777`),只在 QUIC 回调里碰;`conn_ctx` **不加任何 字段** —— 那个结构体在 h1 的**每请求**热路上,往里加一个字都是每个 h1 请求都要付 的。客户端加了六个成员(三个 `bool`、一个 `int64`、两个指针,`src/web/uvcpp_http_client.h:726-732`) —— 那是每**连接**一个的对象,不是每请求一个;`send()` 热路上多的是一个可预测为假 @@ -500,7 +510,7 @@ h1 写泵、TCP 的 ALPN 列表与分支 —— **全部不改**。唯一的例 1. **别指望从公开 h3 头里看到 nghttp3。** `` 只出现在私有的 `src/http3/uvcpp_h3_nghttp3.h` 里,而它和持有 nghttp3 句柄的 - `src/http3/uvcpp_h3_session.h` **两个都不安装**(`CMakeLists.txt:3779-3779`)、打包 + `src/http3/uvcpp_h3_session.h` **两个都不安装**(`CMakeLists.txt:3911-3911`)、打包 也排除。理由与 quic 那一对逐字相同:一是使用者不该被逼着去配 nghttp3 的搜索 路径才能 include 一个本库的头;二是 `uvcpp_h3_session.h` 的字段布局直接跟着 nghttp3 的版本走 —— 一旦漏进公开面,那个版本就变成了本库的 ABI。这处排除与 @@ -517,7 +527,7 @@ h1 写泵、TCP 的 ALPN 列表与分支 —— **全部不改**。唯一的例 3. **只有 FIN、没有数据的块要 `add_write_offset(sid, 0)`。** `nghttp3_conn_writev_stream()` 可能吐出一个零字节、只带 FIN 的块, `add_write_offset()` 无论如何都要调 —— 少了那一句,这个 FIN 永远发不出去。 - 本层的 `flush()` 就是这么写的(`src/http3/uvcpp_h3_session.h:315` 那条注释)。 + 本层的 `flush()` 就是这么写的(`src/http3/uvcpp_h3_session.h:338-338` 那条注释)。 4. **别在 nghttp3 的回调里调它的写函数。** 与 nghttp2 同一条硬规矩:那会在它 自己的栈上重入。本层的处置是"回调里只置 `want_write_`,`recv_stream_data()` @@ -603,6 +613,16 @@ h1 写泵、TCP 的 ALPN 列表与分支 —— **全部不改**。唯一的例 **draft-ietf-webtrans-http3-13**(`webtransport` / `0x41` / `0x54`)。 **没有**子协议协商(`WT_PROTOCOL`)、`WT_MAX_SESSIONS`、重定向与浏览器互操作 验证。 +- **QPACK 编码端动态表可配(`1.13.2-dev` 起)**:`uvcpp_h3_connection::set_qpack_encoder_table_policy()` + 和 `uvcpp_http_server::set_h3_qpack_encoder_table_policy()` 接受 + `h3_qpack_encoder_table_policy::disabled`(默认,容量 0,只用静态表/字面量)、 + `automatic`(保留 `nghttp3_settings_default()` 的 4096)或 + `fixed`(显式容量;0 等同 disabled)。默认 `disabled` 是官方 H3 通过验证的形态: + 动态表条目在 h2load 的时长收尾处可能尚未被解码,造成极少数流被记为 failed; + 关掉编码端动态表换来的是每响应几个字节的头开销,不是重写。**必须在连接 + `start()` 前设置**(服务器级 setter 只影响此后新建的连接);需要按请求或按 + 客户端切换时,用 `uvcpp_h3_connection` 的 setter。该设置只影响本端响应头编码, + 不改变对端 `SETTINGS_QPACK_MAX_TABLE_CAPACITY` 的接收上限。 - **QPACK 的部分可观测已支持(`1.8.3-dev` 起,#53)**:对端的 SETTINGS 走 `callbacks::on_remote_settings` / `remote_settings()`(`qpack_max_dtable_capacity`、 `qpack_blocked_streams`、`enable_connect_protocol`、`h3_datagram`); diff --git a/doc/json-guide.md b/doc/json-guide.md index 944bd816..08beb204 100644 --- a/doc/json-guide.md +++ b/doc/json-guide.md @@ -44,7 +44,7 @@ ## 2. 编译期条件与包含 - **没有开关。** 它是核心模块,`UVCPP_ENABLE_NET` / `_WEB` / `_WEBAPP` 一个都不影响它; - `CMakeLists.txt:1790-1790` 那个收 `src/uvcpp/` 下源文件的 GLOB 已经把它收进去了。 + `CMakeLists.txt:1922-1922` 那个收 `src/uvcpp/` 下源文件的 GLOB 已经把它收进去了。 - **不需要 nlohmann、不需要 OpenSSL、不需要 zlib。** 头文件只带 `` 与 ``,实现只多带 ` `。 - **C++11**(本仓没有 per-target 覆盖),所以没有 `std::string_view`、没有 `if constexpr`。 diff --git a/doc/json-reflect-guide.md b/doc/json-reflect-guide.md index a04ab5c3..b5a93160 100644 --- a/doc/json-reflect-guide.md +++ b/doc/json-reflect-guide.md @@ -93,7 +93,7 @@ struct doc_thing { ``` 两个头都**不在 `` 里**:那个聚合头只收 `uvcpp_define/version/export` 与 -`handle/loop/req` 三组。两个头都被 `CMakeLists.txt:1790-1790` 与 webapp 那份同形的 GLOB 自动 +`handle/loop/req` 三组。两个头都被 `CMakeLists.txt:1922-1922` 与 webapp 那份同形的 GLOB 自动 收进构建与安装,**不需要往任何清单里加一行**。 - **没有开关。** 写出侧不吃 `UVCPP_ENABLE_*` 任何一个;读入侧只吃它本来就依赖的 diff --git a/doc/multiloop-design.md b/doc/multiloop-design.md index 870afc08..6e3c0599 100644 --- a/doc/multiloop-design.md +++ b/doc/multiloop-design.md @@ -302,7 +302,7 @@ DragonFly/Solaris/AIX 生效)。改法是:监听 fd 建一次,`dup()` n | 容器 | 位置 | 触碰频率 | |---|---|---| -| `uvcpp_http_server::contexts_` | `src/web/uvcpp_http_server.h:1844-1844` | **每请求**(`.cpp` 里 52 处引用)—— **已切开**(§4.1) | +| `uvcpp_http_server::contexts_` | `src/web/uvcpp_http_server.h:1875-1875` | **每请求**(`.cpp` 里 52 处引用)—— **已切开**(§4.1) | | ~~`uvcpp_web_app::inflight_`~~ → `loop_slot::inflight` | `src/webapp/uvcpp_web_app.h:2246-2246`(**已切开**,W4 / 2c) | **每请求** | | ~~`uvcpp_web_app::upgraded_`~~ → `loop_slot::upgraded` | `src/webapp/uvcpp_web_app.h:2305-2305`(**已切开**,W4 / 2c) | 每次 WS 升级 | | `uvcpp_tcp_server::clients_` | `src/net/uvcpp_tcp_server.h:967-967` | 接受 / 关闭 / 计数 | @@ -338,7 +338,7 @@ DragonFly/Solaris/AIX 生效)。改法是:监听 fd 建一次,`dup()` n ### 4.1 好消息:大部分切分是"多建几个对象",不是"给容器加锁" -`uvcpp_http_server` 在自己的构造函数里 `new uvcpp_tcp_server`(`src/web/uvcpp_http_server.cpp:281-283`), +`uvcpp_http_server` 在自己的构造函数里 `new uvcpp_tcp_server`(`src/web/uvcpp_http_server.cpp:329-331`), 而 `uvcpp_tcp_server` 在自己的构造函数里 `new uvcpp_loop`(`src/net/uvcpp_tcp_server.cpp:81-85`)。 ⇒ **n 个 `uvcpp_http_server` 实例 = n 份 `contexts_` + n 份 `clients_` + n 条循环/线程。** @@ -346,7 +346,7 @@ DragonFly/Solaris/AIX 生效)。改法是:监听 fd 建一次,`dup()` n > 落地的是**一个实例、内部按循环切表**:`contexts_` 从一张 > `std::map` 变成 > `std::vector >` -> (`src/web/uvcpp_http_server.h:1844-1844`),索引 = `uvcpp_tcp_client::loop_index()`; +> (`src/web/uvcpp_http_server.h:1875-1875`),索引 = `uvcpp_tcp_client::loop_index()`; > 取表只有三个入口 —— `ctxs_of(client)`(有连接时)、`ctxs_here()`(没有连接、 > 靠线程本地的循环号,`src/net/uvcpp_loop_worker.h` 那对 > `uvcpp_loop_index_of_this_thread()`)、`ctxs_at(i)`;`n == 1` 时 @@ -730,20 +730,20 @@ W4 之后改成了**连接自己那条**(`client->get_loop()`),分片用 **这两条是这次重过一遍的产出,之前设计稿与外部复核都没提到它们。** > **一处例外(2026-09-22 修正):压缩变体表不属于这一份。** 它早先被列在上面,是错的 -> —— `uvcpp_http_server::compress_variants_`(`src/web/uvcpp_http_server.h:1945-1945`)是 +> —— `uvcpp_http_server::compress_variants_`(`src/web/uvcpp_http_server.h:1976-1976`)是 > **请求期惰性写**的缓存:命中时改 `last_used` / `compress_variant_clock_` 并计数 -> (`src/web/uvcpp_http_server.cpp:2332-2332`),未命中时插入并可能触发 LRU 淘汰 -> (`src/web/uvcpp_http_server.cpp:2332-2332`、`src/web/uvcpp_http_server.cpp:2110-2110`)。 +> (`src/web/uvcpp_http_server.cpp:2459-2459`),未命中时插入并可能触发 LRU 淘汰 +> (`src/web/uvcpp_http_server.cpp:2459-2459`、`src/web/uvcpp_http_server.cpp:2237-2237`)。 > 多循环下这些写来自**多条循环线程** ⇒ 它和 `compress_variant_clock_` / `_hits_` / -> `_misses_` / `_stored_`(`src/web/uvcpp_http_server.h:1946-1949`)一起加锁; +> `_misses_` / `_stored_`(`src/web/uvcpp_http_server.h:1977-1980`)一起加锁; > **按循环切不成立** —— 它本来就是跨循环共用的缓存,切了就退回每循环各自 deflate。 > -> **已落地**:`mutable std::mutex compress_mu_`(`src/web/uvcpp_http_server.h:1963-1963`) +> **已落地**:`mutable std::mutex compress_mu_`(`src/web/uvcpp_http_server.h:1994-1994`) > 一把**非递归**锁护住那张表与四个计数。加锁点只有三个**外层入口** —— 命中 -> (`src/web/uvcpp_http_server.cpp:2332-2332`)、存入(含淘汰,**同一次临界区**:淘汰那句要读 +> (`src/web/uvcpp_http_server.cpp:2459-2459`)、存入(含淘汰,**同一次临界区**:淘汰那句要读 > 整张表的字节总量,拆成两次加锁会让别的循环插在中间按一个已不成立的总量做决定)、 > `compress_variant_stats()`。两个帮手改名成 `..._locked()` -> (`src/web/uvcpp_http_server.h:1974-1974` / `src/web/uvcpp_http_server.h:1978-1978`),意思就是"调用方已持锁" —— +> (`src/web/uvcpp_http_server.h:2005-2005` / `src/web/uvcpp_http_server.h:2009-2009`),意思就是"调用方已持锁" —— > 淘汰要算字节总量,所以这两个互相调用,同一条非递归锁不能进两次。 > 临界区里只碰表与计数:命中那条路把共享句柄**拷出锁外**再 `share()`, > `finish_headers()` 也在锁外(它改的是响应,不碰表)。 @@ -854,13 +854,13 @@ if (it == ctxs_here().end()) return; // 两个容器的 end() 相比 连接所属的那条循环。§4.1.1 己 那条(工作项投错循环)与"不在任何循环线程上"恰好破坏它 —— 那时比较的是**两个不同容器**的迭代器(标准上是 UB;`std::map` 的 `end()` 是各自表头节点的 地址,于是"找不到"这条早退**恒不成立**),后面紧跟着的 `it->second` 就解引用了 `end()`。 -⇒ 19 处全部改成"表取一次、拿它自己的 `end()` 比";`src/web/uvcpp_http_server.cpp:3025-3025` +⇒ 19 处全部改成"表取一次、拿它自己的 `end()` 比";`src/web/uvcpp_http_server.cpp:3152-3152` 那处 `ctxs_here()` 是**有意的**(`begin_h2_goaway()` 要的就是本循环那张表),不动。 **(二)`ctxs_at(-1)` 在多循环下直接终止,不再夹回 0 号。** `-1` 不是越界,它的含义是 "不在任何循环线程上"(`uvcpp_loop_index_of_this_thread()` 的初值)。单循环下夹回 0 号 与从前逐字相同,那条路原样保留;n > 1 时 0 号只是 n 张里的一张,夹回去会让"漏调了一条循环" -看着正常 —— `begin_h2_goaway()` 的契约是每条循环各调一次(`src/web/uvcpp_http_server.h:417-420`), +看着正常 —— `begin_h2_goaway()` 的契约是每条循环各调一次(`src/web/uvcpp_http_server.h:424-427`), 夹回 0 号时它只向 0 号循环道别,却返回一个像样的条数。错得比崩安静,所以选崩:libuv 对 API 误用也是直接终止(先例见 `src/handle/uvcpp_handle.cpp:363` 引的那句)。 @@ -1010,9 +1010,9 @@ step 3(`uvcpp_web_app::set_loops(n)`,1.2.23-dev)落地时核出来的七 > 这条要写进 `uvcpp_web_app::set_loops()` 的 doc block(理由与出处见 §4.1 的理由更正块)。 > > **停机那一族另有一条硬约束(2026-09-22,外部复核 §1)**:`begin_h2_goaway()` 只翻 -> **本循环**那张表(`src/web/uvcpp_http_server.cpp:3025-3025` 的 `ctxs_here()`),而 +> **本循环**那张表(`src/web/uvcpp_http_server.cpp:3152-3152` 的 `ctxs_here()`),而 > `ctxs_at(-1)` 在 `contexts_.size() > 1` 且调用者不在任何循环线程上时直接 -> `std::abort()`(`src/web/uvcpp_http_server.cpp:509-514`)⇒ **停机那一族必须"每条 +> `std::abort()`(`src/web/uvcpp_http_server.cpp:557-562`)⇒ **停机那一族必须"每条 > 循环各跑一次、且每次都在该循环自己的线程上"**。顺着这条往回看,今天的 `stop()` > (`src/webapp/uvcpp_web_app.cpp:2481-2481`)在 n>1 下是坏的:非循环线程进来时它走 > `post(...)`,而 `post()` 的落点是 0 号(§5.2)⇒ 1..n−1 的停机状态机永远不会被推进, diff --git a/doc/quic-guide.md b/doc/quic-guide.md index 1749dfdc..2e3abd46 100644 --- a/doc/quic-guide.md +++ b/doc/quic-guide.md @@ -42,7 +42,7 @@ - 包含方式:``、``、 ``、``。私有的 `` 与 `` **都不安装** - (`CMakeLists.txt:3756-3756`)—— 理由见 [§7](#7-典型坑) 第一条。 + (`CMakeLists.txt:3888-3888`)—— 理由见 [§7](#7-典型坑) 第一条。 - 四个公开头**全部**整段套在 `#if UVCPP_QUIC_ENABLE` 里,所以**不开关就一个类都 看不到**。这与 `web/`、`ssl/`、`http2/`、`http3/`、`wsdl/` 同档。 @@ -181,7 +181,7 @@ PMTUD 会把 path MTU 从 1200 抬到 1444:设大了协议栈**切在包中间 刚开始时报的是 `10 × max_udp_payload_size` = 12000(`ngtcp2:lib/ngtcp2_cc.c:53` 覆盖掉了 `ngtcp2:lib/ngtcp2_conn.c:923` 那个 64 KiB),然后随 PMTUD 上抬。缓冲要是按**当前值**开, 聚合就被压在 8 个包上下(本机实测过这个形状)。开成 64 KiB 上限(`kGsoBufLen`, -`src/quic/uvcpp_quic_session.cpp:143`),让 ngtcp2 自己那条 `ngtcp2_min(buflen, +`src/quic/uvcpp_quic_session.cpp:144`),让 ngtcp2 自己那条 `ngtcp2_min(buflen, send_quantum)`(`ngtcp2:lib/ngtcp2_conn.c:14304`)去限才是对的形状。下限仍是 `kDatagramBufLen`: agg2 里有 `assert(buflen >= path_max_udp_payloadlen)`。 @@ -194,7 +194,7 @@ agg2 里有 `assert(buflen >= path_max_udp_payloadlen)`。 建 socket 的 —— `uv_udp_init`(AF_UNSPEC)之后 `handle->socket` 还是 `INVALID_SOCKET`,这时 `uv_fileno` 返回 `UV_EBADF`,`setsockopt` 无从谈起。本机实测: bind 前 `fileno rc=-4083 sock=-1`,bind 后 `rc=0 sock=628`。所以探测点落在 -`init_client()`/`init_server()` 的末尾(`setup_gso()`,`src/quic/uvcpp_quic_session.cpp:1192`), +`init_client()`/`init_server()` 的末尾(`setup_gso()`,`src/quic/uvcpp_quic_session.cpp:1259`), 不是建对象的时候。 **坑二:`setsockopt` 成功 ≠ 协议栈真会切。** 本机实测 512…65483 **全都返回成功**, @@ -256,7 +256,7 @@ nghttp2 / zlib / pugixml 的用法一致。 ``` ngtcp2 integrated (tag=v1.25.0, static) # CMakeLists.txt:1117-1117 -Including quic module in build (ngtcp2 v1.25.0) # CMakeLists.txt:2449-2449 +Including quic module in build (ngtcp2 v1.25.0) # CMakeLists.txt:2581-2581 ``` > **只 grep `CMakeCache.txt` 是不够的。** 三条降级用的都是**普通变量** @@ -644,7 +644,7 @@ if (conn.stats(st)) { 1. **别指望从公开头里看到 ngtcp2。** `` 只出现在私有的 `src/quic/uvcpp_quic_ngtcp2.h` 里,而它和持有 ngtcp2 句柄的 - `src/quic/uvcpp_quic_session.h` **两个都不安装**(`CMakeLists.txt:3756-3756`)、打包 + `src/quic/uvcpp_quic_session.h` **两个都不安装**(`CMakeLists.txt:3888-3888`)、打包 也被排除。理由有两条:一是使用者不该被逼着去配 ngtcp2 的搜索路径才能 include 一个本库的头;二是 `uvcpp_quic_session.h` 的成员里就有 `ngtcp2_conn*`、`SSL*`、 `ngtcp2_path_storage`,它的字段布局直接跟着 ngtcp2 的版本走 —— 一旦漏进公开面, @@ -658,8 +658,8 @@ if (conn.stats(st)) { 调用,符号在链接期解析,照样证明 ngtcp2 真被链上。 3. **`src/quic/` 的源文件被 `list(FILTER … EXCLUDE REGEX "src/quic/")` 排除** - (`CMakeLists.txt:2444-2444`,头文件那一条在 `:2228`),而且"开了 QUIC 但目录是空的" - 会**当场 FATAL**(`CMakeLists.txt:2458-2458`)。后者防的是一棵树同时骗过三道看起来 + (`CMakeLists.txt:2576-2576`,头文件那一条在 `:2228`),而且"开了 QUIC 但目录是空的" + 会**当场 FATAL**(`CMakeLists.txt:2590-2590`)。后者防的是一棵树同时骗过三道看起来 很像门禁的东西:cache 里 `QUIC=ON`、日志里有 `ngtcp2 integrated`、编译也过 —— 而 `src/quic/` 一个 `.cpp` 都没有,**零行 QUIC 代码被编译过**。"没测"必须表现为 **失败**,不是表现为**通过**。 diff --git a/doc/ssl-guide.md b/doc/ssl-guide.md index e83a1b24..cd861275 100644 --- a/doc/ssl-guide.md +++ b/doc/ssl-guide.md @@ -42,7 +42,7 @@ TLS 在这库里是**过滤层**,不是独立的传输实现:装到 `uvcpp_t |---|---|---| | `uvcpp_ssl_context` | `src/ssl/uvcpp_ssl_context.h:33-33` | **主类型**。一个上下文可以共享给多条连接(`:8-9`) | | `uvcpp_ssl` | `src/ssl/uvcpp_ssl.h:33` | 每连接包装(一个 `SSL*`),`uvcpp_tcp_client` 内部持有 | -| `ssl_detail::alpn_wire_format` | `src/ssl/uvcpp_ssl_common.h:100` | 把 ALPN 名单编成线格式的自由函数,实现细节 | +| `ssl_detail::alpn_wire_format` | `src/ssl/uvcpp_ssl_common.h:110` | 把 ALPN 名单编成线格式的自由函数,实现细节 | 值类型在 `ssl/uvcpp_ssl_common.h`:`tls_version`、`tls_mode`、`tls_verify_mode`、 `tls_ctx_status`、`tls_cert_info`。 @@ -65,7 +65,7 @@ TLS 在这库里是**过滤层**,不是独立的传输实现:装到 `uvcpp_t 或链接错误**,只会在运行时读到错位的垃圾。 关掉这个选项时:`src/ssl/` 会被从源文件与头文件列表里排除,**而且根本不安装 ssl 头** -(`CMakeLists.txt:3728-3729`)——使用者连 `#include ` 都会 +(`CMakeLists.txt:3860-3861`)——使用者连 `#include ` 都会 找不到文件。同理,`uvcpp_tcp_server::set_ssl_context()` 在关掉时**连声明都不存在**。 运行时"关掉 TLS"不是宏,是 `set_ssl_context(nullptr)`。 @@ -254,22 +254,26 @@ QUIC,`uvcpp_http_client` 明确返回空链 / `-1` / 说明串 —— 不是 ```cpp // doc-snippet: fragment — 接口签名摘录,与 §4、§7 那几张表同类的东西。 bool set_alpn_protos(const std::vector& protos); // 上下文级 -void set_alpn_select_protos(const std::vector& protos); // 服务端 +void set_alpn_select_protos(const std::vector& protos, // 服务端 + alpn_mismatch on_mismatch = alpn_mismatch::NOACK); bool has_alpn_select() const; ``` **这里有一个反过来的返回值约定:`SSL_CTX_set_alpn_protos` 成功返回 0**,与 OpenSSL -大多数接口相反(`src/ssl/uvcpp_ssl_context.cpp:643-643` 专门写了注释)。本库的包装把它 +大多数接口相反(`src/ssl/uvcpp_ssl_context.cpp:620-620` 专门写了注释)。本库的包装把它 翻正成 `bool`,但如果绕到 `raw_ctx()` 自己调,记住这条。 其他要点: - 名单里**空串或长度超过 255 字节的项会被静默丢掉**,不报错;全部丢完导致编码为空时 - `set_alpn_protos` 返回 `false`(`src/ssl/uvcpp_ssl_common.h:94-97`)。 -- 服务端**挑不中时返回 `SSL_TLSEXT_ERR_NOACK`,不是 fatal** - (`src/ssl/uvcpp_ssl_context.h:187-189`)——写成 fatal 会让所有老客户端连握手都完不成。 + `set_alpn_protos` 返回 `false`(`src/ssl/uvcpp_ssl_common.h:104-107`)。 +- 服务端挑不中时**默认返回 `SSL_TLSEXT_ERR_NOACK`,不是 fatal** + (`src/ssl/uvcpp_ssl_context.h:189-195`)——写成 fatal 会让所有老客户端连握手都完不成。 + 需要 RFC 7301 §3.2 的严格语义时传 `alpn_mismatch::FATAL`,服务端会回 + `no_application_protocol` alert(120);**QUIC 一律用这一档**(RFC 9001 §8.1: + ALPN 是 QUIC 的强制协商项,没有它就没有协议可跑,`uvcpp_quic_server` 自动这么设)。 - `has_alpn_select()` 存在的理由是框架默认值与用户策略的冲突:`uvcpp_web_app` 默认要 - 替使用者宣告 h2,但**不会覆盖已经显式设过的名单**(`src/ssl/uvcpp_ssl_context.h:227-233`)。 + 替使用者宣告 h2,但**不会覆盖已经显式设过的名单**(`src/ssl/uvcpp_ssl_context.h:234-240`)。 - 每连接的覆盖在 `uvcpp_ssl::set_alpn_protos`,**必须在握手前**调。 ### 6.1 SNI:一套证书不够用时(1.9.0) @@ -313,9 +317,9 @@ srv.add_sni_certificate_file("*.static.example.com", "static.pem", "static.key") 顺序:`set_ssl_context` **必须在 `listen()` 之前**(`:346-347`),清空用 `set_ssl_context(nullptr)`。而且它是**在 loop 线程调用**的。 -上下文对象本身的地址被 OpenSSL 长期持有——ALPN 选择回调通过 `arg` 拿到的就是成员 -`alpn_select_wire_` 的地址(`src/ssl/uvcpp_ssl_context.h:284-284`,实现 -`SSL_CTX_set_alpn_select_cb(ctx_, alpn_select_cb, &alpn_select_wire_)`)。 +上下文对象本身的地址被 OpenSSL 长期持有——ALPN 选择回调通过 `arg` 拿到的就是上下文 +对象本身(`this`,回调按 `alpn_select_wire_` / `alpn_select_fatal_` 两格成员判交集)(`src/ssl/uvcpp_ssl_context.h:295-295`,实现 +`SSL_CTX_set_alpn_select_cb(ctx_, &uvcpp_ssl_context::alpn_select_cb, this)`)。 **所以不要移动它、不要提前析构它。** `uvcpp_ssl::use_memory_bio()` **必须在任何握手/IO 之前**调(`src/ssl/uvcpp_ssl.h:100`)。 diff --git a/doc/web-http-guide.md b/doc/web-http-guide.md index 6d79534c..7c14617d 100644 --- a/doc/web-http-guide.md +++ b/doc/web-http-guide.md @@ -47,9 +47,9 @@ ## 1. 这一层是什么 `uvcpp_http_server` **不是从零写的 socket 服务器** —— 它建在 `uvcpp_tcp_server` -之上(`src/web/uvcpp_http_server.cpp:281-283`:构造函数第一件事就是 +之上(`src/web/uvcpp_http_server.cpp:329-331`:构造函数第一件事就是 `new uvcpp_tcp_server()`),每条连接配一个独立的 `uvcpp_http_parser` 上下文 -(`src/web/uvcpp_http_server.h:1844-1844` 的 `contexts_` —— 装的是**每连接状态**, +(`src/web/uvcpp_http_server.h:1875-1875` 的 `contexts_` —— 装的是**每连接状态**, 单循环时它是一张 `std::map`;多循环下它按循环分成 若干张,取表见 `doc/multiloop-design.md` §4.1)。 @@ -65,7 +65,7 @@ (``)。web 层的异步续跑只有一条路:`resp.deferred = true`。 **三、`web/` 有 h2,但入口有三条。** 服务端 `set_http2_enabled(true)` -(`src/web/uvcpp_http_server.h:357-357`)加 TLS+ALPN,服务端 `set_h2c_enabled(true)` +(`src/web/uvcpp_http_server.h:364-364`)加 TLS+ALPN,服务端 `set_h2c_enabled(true)` (明文先验知识,RFC 9113 §3.4),客户端 `set_http2_enabled(true)` (`src/web/uvcpp_http_client.h:696-696`)。 前两条都**默认关**;只有 `webapp/` 框架层默认开、零配置自动协商。 @@ -87,10 +87,10 @@ | HTTP/2 | `UVCPP_NGHTTP2_ENABLE` | `set_http2_enabled()` 那一组消失 | 两行"响应压缩"是**同一个块的两个来源**:压缩器的总开关是 -`UVCPP_HTTP_COMPRESS_ENABLE`,它由那两个宏**或**出来(`CMakeLists.txt:2226-2226`)—— +`UVCPP_HTTP_COMPRESS_ENABLE`,它由那两个宏**或**出来(`CMakeLists.txt:2358-2358`)—— 任一为 1 就有这个块,两个都为 0 才整块消失。三个"块"的开关都默认 OFF,brotli 那条也是(`CMakeLists.txt:302-316` 那一组 `option()`,四个块开关默认全是 OFF)。编译进 `UVCPP_SRC_FILES` 的是 -`src/web/*.cpp` 全体(`CMakeLists.txt:1804-1804`),但每个 `.cpp` 里的功能块同样带宏。 +`src/web/*.cpp` 全体(`CMakeLists.txt:1936-1936`),但每个 `.cpp` 里的功能块同样带宏。 `uvcpp_http_server` **自己不碰 TLS** —— 它没有任何 SSL API。要上 https 必须 `get_tcp_server()->set_ssl_context(...)`,**而且必须在 `listen()` 之前** @@ -101,7 +101,7 @@ ## 3. 最小服务端 -这就是 `src/web/uvcpp_http_server.h:163-172` 那段官方示例(我把它补成了完整 TU): +这就是 `src/web/uvcpp_http_server.h:170-179` 那段官方示例(我把它补成了完整 TU): ```cpp #include @@ -129,8 +129,8 @@ int main() { ``` `bind` / `bindIpv4` / `bindIpv6` / `listen` 四个都在这里转调 `uvcpp_tcp_server`, -返回 libuv 错误码(`src/web/uvcpp_http_server.cpp:640-669`)。`listen` 的默认 backlog 是 -128(`src/web/uvcpp_http_server.h:218-218`)。四个里只有 `listen` 多做一件事:转调之前 +返回 libuv 错误码(`src/web/uvcpp_http_server.cpp:688-717`)。`listen` 的默认 backlog 是 +128(`src/web/uvcpp_http_server.h:225-225`)。四个里只有 `listen` 多做一件事:转调之前 先把每循环的上下文表按 `loop_count()` 定型 —— 多循环时工作循环的线程是在 `set_loops()` 里放行的,等它接手连接再取表就晚了(`doc/multiloop-design.md` §4)。 @@ -151,13 +151,13 @@ void doc_graceful_shutdown(uvcpp::uvcpp_http_server& server) { ``` 想一步到位就两个都调。连接级的 `close_connection()` 是 **private** -(`src/web/uvcpp_http_server.h:1425-1425`)—— 单个连接只能从 `uvcpp_tcp_client` 那侧关。 +(`src/web/uvcpp_http_server.h:1452-1452`)—— 单个连接只能从 `uvcpp_tcp_client` 那侧关。 --- ## 4. 路由与匹配规则 -注册 API **全部返回 `void`**,没有失败通道(`src/web/uvcpp_http_server.h:502-535`): +注册 API **全部返回 `void`**,没有失败通道(`src/web/uvcpp_http_server.h:522-555`): ```cpp #include @@ -189,7 +189,7 @@ void doc_routes(uvcpp::uvcpp_http_server& server) { } ``` -**匹配规则(`src/web/uvcpp_http_server.cpp:996-1015`):剥掉 query 再逐字节比路径, +**匹配规则(`src/web/uvcpp_http_server.cpp:1050-1069`):剥掉 query 再逐字节比路径, 线性扫描,首次命中即返回。** 于是: - **没有参数、没有通配、没有正则、没有中间件**(`src/webapp/uvcpp_web_router.h:9-14` @@ -197,17 +197,17 @@ void doc_routes(uvcpp::uvcpp_http_server& server) { - **重复注册同一路径时先注册的赢,后面的永远不可达** —— 而 API 返回 `void`, 没有任何提示。 - 都没命中 → `default_handler_`;`default_handler_` 为空 → 直接 **404** - (`src/web/uvcpp_http_server.cpp:1545-1550`)。 + (`src/web/uvcpp_http_server.cpp:1672-1677`)。 - **分不出 404 和 405**:`get("/x")` 已注册时来一个 `POST /x`,走的还是兜底 或 404,不会回 405。 -路由表就是个 `std::vector`(`src/web/uvcpp_http_server.cpp:971-994`), +路由表就是个 `std::vector`(`src/web/uvcpp_http_server.cpp:1025-1048`), `listen()` 之后仍可以改;但它没有锁。 ### 请求目标里的 query 要自己解 **web 层不提供任何 query / cookie / form / URL 解码工具,`req.url` 就是原始请求目标 -(含 `?query`)。** 路由匹配时会把 query 剥掉再去比(`src/web/uvcpp_http_server.cpp:998-1001`), +(含 `?query`)。** 路由匹配时会把 query 剥掉再去比(`src/web/uvcpp_http_server.cpp:1052-1055`), 但**解析 query 是 handler 自己的事** —— 这一层没有这个函数。要用就在 `webapp/` 的 `web_parse_query()`(`src/webapp/uvcpp_web_util.h:205-205`)或者自己写一个。 @@ -222,7 +222,7 @@ void doc_routes(uvcpp::uvcpp_http_server& server) { 接进来的(`src/webapp/uvcpp_web_app.cpp:2188-2188`)。 `stream_handler` 拿到的 `req` 是 `ctx.stream_request`,**头部视图只在当次调用内有效, -要留就自己拷**(`src/web/uvcpp_http_server.h:119-121`)。 +要留就自己拷**(`src/web/uvcpp_http_server.h:133-135`)。 --- @@ -290,7 +290,7 @@ h2 连接上要么自己设回去,要么改用带 `stream_id` 的 `send_respon ## 6. 异步响应 **handler 返回之前没发响应,就再也没机会发了** —— 除非把 `resp.deferred` 置真。 -框架见到它就直接 return(`src/web/uvcpp_http_server.cpp:1556-1557`), +框架见到它就直接 return(`src/web/uvcpp_http_server.cpp:1683-1684`), 由你自己在之后(且必须在 loop 线程上)把响应送出去。 ### 6.1 `req.reply` + `send_reply()`(`1.6.8-dev` 起,**推荐**) @@ -352,19 +352,19 @@ h1 / h2 上还有一条**逐字等价**的老路:手里那个 `uvcpp_tcp_clien `uvcpp_static_server` 走过它很多年),但 **h3 上不成立** —— 那条腿上第三个形参恒为 `nullptr`,没有 `client` 可记。新代码用 [§6.1](#61-reqreply--send_reply168-dev-起推荐)。 -`connection_generation()`(`src/web/uvcpp_http_server.h:894-894`)是本层最容易被忽略、 +`connection_generation()`(`src/web/uvcpp_http_server.h:914-914`)是本层最容易被忽略、 又最容易出致命错的 API:**返回 0 表示这条连接已经不在服务器的登记表里,此时不该写它。** 代次号单调递增、永不复用,所以"连接还活着"时号不变、"地址被新连接复用"时号对不上 -(`src/web/uvcpp_http_server.h:1803-1813`)。`is_connected()` 就是 `generation != 0`(`src/web/uvcpp_http_server.h:897-897`)。 +(`src/web/uvcpp_http_server.h:1834-1844`)。`is_connected()` 就是 `generation != 0`(`src/web/uvcpp_http_server.h:917-917`)。 **`send_response()` 会把 `resp.body` 移走。** 两块写(`nbufs = 2`)时 body 被 `std::move`,之后 `resp.body.size()` 是 0。要记"上线了多少 body"就用它的**返回值** -(`src/web/uvcpp_http_server.h:716-729`)。webapp 正是这么记访问日志的。 +(`src/web/uvcpp_http_server.h:736-749`)。webapp 正是这么记访问日志的。 `deferred` 的标志位在**检查之后会被清掉**,所以那个 `resp` 对象不必一直活着 —— 但你要发送的那一份得自己留着。 **`stop()` 与 `close_all_clients()` 都不唤醒写队列里的 `done`** -(`src/web/uvcpp_http_server.cpp:379-381` 明说)。 +(`src/web/uvcpp_http_server.cpp:427-429` 明说)。 --- @@ -402,7 +402,7 @@ void doc_stream(uvcpp::uvcpp_http_server& server) { } ``` -**`write_stream` 的 `done` 契约(`src/web/uvcpp_http_server.h:771-794`):** +**`write_stream` 的 `done` 契约(`src/web/uvcpp_http_server.h:791-814`):** - 入队后**保证恰好一次**,**包括连接还在队列里就被关掉的场合**; - **但只有 `write_stream` 返回 0 才有这个保证** —— 非 0 时 `done` **不会被调**, @@ -410,24 +410,24 @@ void doc_stream(uvcpp::uvcpp_http_server& server) { - `done` **绝不在函数返回前同步跑**(`:487`)。 **同名方法在 h1 与 h2 上含义不同,而且没有编译期区分手段** -(`src/web/uvcpp_http_server.h:768-815`): +(`src/web/uvcpp_http_server.h:788-835`): | | h1 | h2 | |---|---|---| | `write_stream(client, bytes, ...)` | `bytes` 是**已组好 chunked 帧**的字节 | `bytes` 是**裸 body** | | `end_stream(client, close_after)` | 可能关连接 | **不关连接**,只发 `END_STREAM` | -| 在 h2 连接上调 h1 那两个重载 | `write_stream` 返回 `UV_EINVAL`、`end_stream` **静默返回**(`src/web/uvcpp_http_server.cpp:1932-1932`、`src/web/uvcpp_http_server.cpp:1961-1961`)/ `begin_stream(client, resp)` 打一条 stderr 后丢弃(`src/web/uvcpp_http_server.cpp:1833-1838`) | — | +| 在 h2 连接上调 h1 那两个重载 | `write_stream` 返回 `UV_EINVAL`、`end_stream` **静默返回**(`src/web/uvcpp_http_server.cpp:2059-2059`、`src/web/uvcpp_http_server.cpp:2088-2088`)/ `begin_stream(client, resp)` 打一条 stderr 后丢弃(`src/web/uvcpp_http_server.cpp:1960-1965`) | — | **`is_head` 与 `accept_encoding` 是连接级单槽,h2 上必须按流记。** -`src/web/uvcpp_http_server.h:1091-1130` 把三类后果写得很细;`send_h2_response` 里 +`src/web/uvcpp_http_server.h:1111-1150` 把三类后果写得很细;`send_h2_response` 里 是临时把"这条流的值借到连接级字段"再调压缩的 -(`src/web/uvcpp_http_server.cpp:3268-3276`)。 +(`src/web/uvcpp_http_server.cpp:3395-3403`)。 ### 升级到别的协议 -`on_upgrade(handler)`(`src/web/uvcpp_http_server.h:445`)是单槽(`src/web/uvcpp_http_server.cpp:943-945`)。 +`on_upgrade(handler)`(`src/web/uvcpp_http_server.h:452-452`)是单槽(`src/web/uvcpp_http_server.cpp:991-993`)。 它被调时这条连接已经从 http 解析里摘出来了,之后的字节归你;升级时**已经读进来但 -还没解析的字节**用 `take_upgrade_leftover(client)`(`src/web/uvcpp_http_server.h:499-499` / `src/web/uvcpp_http_server.cpp:961-961`)取走 —— +还没解析的字节**用 `take_upgrade_leftover(client)`(`src/web/uvcpp_http_server.h:519-519` / `src/web/uvcpp_http_server.cpp:1015-1015`)取走 —— 客户端把 `Upgrade` 请求与第一帧 WebSocket 数据包在同一个 TCP 段里发过来是合法的, 少了这一步那一帧就永远丢了。 @@ -742,7 +742,7 @@ p99 **170.5 ms → 140.5 ms**。读数与口径见 [`benchmark.md`](benchmark.md ## 10. 上限与旋钮 -**三个上限的默认值全是 0,也就是全都不限**(`src/web/uvcpp_http_server.h:1799-1801`): +**三个上限的默认值全是 0,也就是全都不限**(`src/web/uvcpp_http_server.h:1830-1832`): | 旋钮 | 默认 | 越限的答复 | |---|---|---| @@ -751,36 +751,36 @@ p99 **170.5 ms → 140.5 ms**。读数与口径见 [`benchmark.md`](benchmark.md | `set_max_url_bytes(n)` | 0 = 不限 | **414 + `Connection: close`** | **三者"生效时机"不一致**:头/URL 上限在 accept 时被拷进解析器 -(`src/web/uvcpp_http_server.cpp:1045-1046`)⇒ **listen 之后改它只对新连接生效**; -`max_body_size_` 是每块 body 现读成员(`src/web/uvcpp_http_server.cpp:1108-1108`)⇒ **立刻生效**。 +(`src/web/uvcpp_http_server.cpp:1099-1100`)⇒ **listen 之后改它只对新连接生效**; +`max_body_size_` 是每块 body 现读成员(`src/web/uvcpp_http_server.cpp:1162-1162`)⇒ **立刻生效**。 三处头文件注释一个字都没提这个区别。 **头/URL 上限对"被 claim 的请求"照样生效。** 这两道是在 llhttp 的头部回调里边收边判的 -(`src/web/uvcpp_parser` 侧 `src/web/uvcpp_http_parser.cpp:430-478`),而 claim hook -是在 `headers_complete` 才被问的(`src/web/uvcpp_http_server.cpp:1115-1191`)。 +(`src/web/uvcpp_parser` 侧 `src/web/uvcpp_http_parser.cpp:433-493`),而 claim hook +是在 `headers_complete` 才被问的(`src/web/uvcpp_http_server.cpp:1169-1245`)。 所以被认领的请求**照样会被 414/431 拒掉并直接关连接**,认领者连 `HEADERS` 事件 -都收不到。**只有 `max_body_size` 真正停在认领边界**(`src/web/uvcpp_http_server.cpp:1098-1114`)—— -头文件把这条区别写在了 `src/web/uvcpp_http_server.h:565-568`(「a claimed request is not exempt」) -与 `:126-128`(`max_body_size` 豁免)两处。 +都收不到。**只有 `max_body_size` 真正停在认领边界**(`src/web/uvcpp_http_server.cpp:1152-1168`)—— +头文件把这条区别写在了 `src/web/uvcpp_http_server.h:585-588`(「a claimed request is not exempt」) +与 `src/web/uvcpp_http_server.h:133-135`(`max_body_size` 豁免)两处。 **头/URL 是"边收边判"的**:一超就停,代价有界,而不是先收完再判 -(`src/web/uvcpp_http_server.h:555-560`)。 +(`src/web/uvcpp_http_server.h:575-580`)。 ### 压缩 -zlib 编进来时**压缩默认开**(`src/web/uvcpp_http_server.h:1906-1906`),最小 body 1024 -(`src/web/uvcpp_http_server.h:1906-1906`),排除的 MIME 走 `default_excluded_mime_types()` +zlib 编进来时**压缩默认开**(`src/web/uvcpp_http_server.h:1937-1937`),最小 body 1024 +(`src/web/uvcpp_http_server.h:1937-1937`),排除的 MIME 走 `default_excluded_mime_types()` (`src/web/uvcpp_http_compress.cpp:216-242`)。压缩变体缓存三道限: -单条 ≤ 4 MiB、总量 ≤ 32 MiB、条数 ≤ 1024(`src/web/uvcpp_http_server.cpp:2039-2049`)。 +单条 ≤ 4 MiB、总量 ≤ 32 MiB、条数 ≤ 1024(`src/web/uvcpp_http_server.cpp:2166-2176`)。 **第五个旋钮:档位。** `set_compress_level()` / `compress_level()` -(`src/web/uvcpp_http_server.h:651-651`),默认 `-1`(zlib 的 +(`src/web/uvcpp_http_server.h:671-671`),默认 `-1`(zlib 的 `Z_DEFAULT_COMPRESSION`,今天等价第 6 档),传进来的值由 `http_compress::clamp_compress_level()`(`src/web/uvcpp_http_compress.h:112-112`) 夹进 `-1` 与 0..9 —— 越界不报错,落到最近的端点上。它和上面那四个**不是一类**: 那四个改的是**要不要压**,档位改的是**压成哪些字节**,压这件事照样发生。所以档位 **进变体缓存的键**(`编码字符 + 档位字符 + cache_tag`, -`src/web/uvcpp_http_server.cpp:2254-2254`;两个定长前缀使键对"编码 + 档位 + tag" +`src/web/uvcpp_http_server.cpp:2381-2381`;两个定长前缀使键对"编码 + 档位 + tag" 单射),换档必然 miss 必然重压,而旧档位那条**留在表里** —— 换回去还能拿回它自己的 字节(`test_compress_level()` 钉的就是这一发)。它也可以在服务跑着的时候改:成员是 原子的,改完下一个请求就按新档位来。档位只改字节、不改内容,解压回来永远逐字节等于 @@ -798,14 +798,14 @@ zlib 编进来时**压缩默认开**(`src/web/uvcpp_http_server.h:1906-1906` 默认档下单份语料比 gzip 6 档**小 11 % 左右**,而每请求的代价与 gzip 相同 —— 因为压缩变体命中时只是一次 `std::map` 查找加一次 `shared_ptr` 交接,编码名只 出现在**键**里(`编码字符 + 档位字符 + cache_tag`),两条路走的是同一条 -(`src/web/uvcpp_http_server.cpp:2253-2256`)。反过来说:**不填 `cache_tag` 就 +(`src/web/uvcpp_http_server.cpp:2380-2383`)。反过来说:**不填 `cache_tag` 就 每请求重压一遍**,那时 `br` 比 gzip 更贵(本机 8.4 KB 那份:gzip 51.6 µs、 `br` 88.6 µs —— 这一遍里有一半以上花在**编码器状态每请求重建**要的那 ~728 KB 上, 把它改成线程本地竞技场之后同一把尺子上 `br` 掉到 88.57 µs、`br`/`gzip` 由 3.25 降到 1.78,详见 `benchmark.md` §4.17;**但仍没过 gzip**),所以"要不要开"取决于条目 有没有把响应体的指纹写进 `cache_tag`。 `br` 没有独立的质量旋钮:`set_compress_level()` -(`src/web/uvcpp_http_server.h:651`)只管 gzip/deflate 那个量纲(`-1` 与 0..9), +(`src/web/uvcpp_http_server.h:671-671`)只管 gzip/deflate 那个量纲(`-1` 与 0..9), `br` 用 `0..11`,两把尺子不能共用(`clamp_brotli_quality()` 与 `clamp_compress_level()` 之所以不合并,就是这条)。**`.br` 孪生文件与这个开关 无关**:`http_pick_precompressed_variants()`(`src/web/uvcpp_http_common.h:679-679`) @@ -824,35 +824,35 @@ CPU,产物还**比原文件大**(本仓语料 22 528 → 22 556、18 432 → ### 协议行为 - **keep-alive**:HTTP/1.1 默认开、1.0 默认关;handler 显式设了 `connection` - 头就听 handler 的(`src/web/uvcpp_http_server.cpp:1716-1730`)。webapp 这一层 + 头就听 handler 的(`src/web/uvcpp_http_server.cpp:1843-1857`)。webapp 这一层 还会在**发送前**把「**这一条**请求自己」的结论钉成显式头 (`src/webapp/uvcpp_web_app.cpp:2916-2919`)——HTTP 层那边现问的是**连接级**的 解析器状态,而 llhttp 的 flags 属于「最近一条解析完的报文」:流水线里末条写 `Connection: close` 时,第 1 条响应(异步的那条)序列化时读到的已经是末条的 结论,服务器会在第 1 条之后关连接、丢掉第 2..N 条(`1.6.46-dev` 修的)。 - **`Date` 每个响应都发,且按秒缓存**:四个出报文的口子各补一次 —— - `send_response`(`src/web/uvcpp_http_server.cpp:1664-1664`)、h1 流式 - `begin_stream`(`src/web/uvcpp_http_server.cpp:1864-1864`)、h2 流式 - `begin_stream`(`src/web/uvcpp_http_server.cpp:1897-1897`)、h2 整包 - `send_h2_response`(`src/web/uvcpp_http_server.cpp:3260-3260`)。值由 + `send_response`(`src/web/uvcpp_http_server.cpp:1791-1791`)、h1 流式 + `begin_stream`(`src/web/uvcpp_http_server.cpp:1991-1991`)、h2 流式 + `begin_stream`(`src/web/uvcpp_http_server.cpp:2024-2024`)、h2 整包 + `send_h2_response`(`src/web/uvcpp_http_server.cpp:3387-3387`)。值由 `uvcpp::http_date()` 造(`src/web/uvcpp_http_date.cpp:86-107`):IMF-fixdate、 **恒 GMT**,星期名与月份名是写死的 ASCII 表 —— 它**不**用 `strftime` 的 `%a`/`%b`,那两个说明符在 `setlocale(LC_TIME, "")` 之后会吐本地文字,对端 解析不了。handler 自己设过 `Date` 就不覆盖 (`src/web/uvcpp_http_date.cpp:114-124`)。1xx 那两条报文是**裸字节**直接写 出去的、没经这个收口,所以不带 `Date`:`100 Continue` - (`src/web/uvcpp_http_server.cpp:1210-1210`)与 WebSocket 握手 + (`src/web/uvcpp_http_server.cpp:1264-1264`)与 WebSocket 握手 (`src/web/uvcpp_ws_server.cpp:249-249`)—— RFC 9110 §6.6.1 对 1xx 只是 **可发**,不发也合规;这是"没经手",不是"写了排除"。 - **`Expect: 100-continue` 支持**,且在 headers 回调里就补 - `HTTP/1.1 100 Continue\r\n\r\n` 裸字节(`src/web/uvcpp_http_server.cpp:1196-1211`)—— 注释解释了为什么 + `HTTP/1.1 100 Continue\r\n\r\n` 裸字节(`src/web/uvcpp_http_server.cpp:1250-1265`)—— 注释解释了为什么 不能用 `send_response()`(1xx 不该带 `Content-Length`)。HTTP/1.0 上 `Expect` - 被忽略(`src/web/uvcpp_http_server.cpp:1565-1570`);**未知的 `Expect` 回 417**(`src/web/uvcpp_http_server.cpp:1580-1585`)。 -- **声明的 `Content-Length` 超限 → body 还没到就回 413**(`src/web/uvcpp_http_server.cpp:1588-1600`)。 -- **畸形报文走正规响应路径回 400 + `Connection: close`**(`src/web/uvcpp_http_server.cpp:1375-1384`), + 被忽略(`src/web/uvcpp_http_server.cpp:1692-1697`);**未知的 `Expect` 回 417**(`src/web/uvcpp_http_server.cpp:1707-1712`)。 +- **声明的 `Content-Length` 超限 → body 还没到就回 413**(`src/web/uvcpp_http_server.cpp:1715-1727`)。 +- **畸形报文走正规响应路径回 400 + `Connection: close`**(`src/web/uvcpp_http_server.cpp:1479-1488`), 不是手搓字节。 - **流水线**:一次读里可以有多条报文,解析器按消息边界 reset - (`src/web/uvcpp_http_server.cpp:1072-1095`、`src/web/uvcpp_http_server.cpp:1323-1339`);**web 层不限条数**,webapp 才限。 + (`src/web/uvcpp_http_server.cpp:1126-1149`、`src/web/uvcpp_http_server.cpp:1427-1443`);**web 层不限条数**,webapp 才限。 ### 没有的旋钮 @@ -870,12 +870,12 @@ CPU,产物还**比原文件大**(本仓语料 22 528 → 22 556、18 432 → 常见值 `UV_ENOTCONN`、`UV_ENOTSUP`、`UV_ETIMEDOUT`、`UV_ECONNRESET`、`UV_EINVAL`。 2. **回调里的 `err` 参数**:客户端 `(resp, err)`、流式写的 `done(int)`。 3. **返回值加 stderr**:`send_response` 在连接已不在表里时**打一条 stderr 警告 - 并返回 0**(`src/web/uvcpp_http_server.cpp:1648-1658`);`begin_stream` 同理 - (`src/web/uvcpp_http_server.cpp:1816-1823`)—— 但它是 `void`,你**无从判断**。 + 并返回 0**(`src/web/uvcpp_http_server.cpp:1775-1785`);`begin_stream` 同理 + (`src/web/uvcpp_http_server.cpp:1943-1950`)—— 但它是 `void`,你**无从判断**。 **异常只在一处被接住**:`on_connection` / `stream_claim` / h2 连接钩子三个钩子 -里抛出的异常会被吞掉并打 stderr(`src/web/uvcpp_http_server.cpp:1058-1069`、`src/web/uvcpp_http_server.cpp:1164-1175`、`src/web/uvcpp_http_server.cpp:3055-3064`)。 -**`handler(req, resp, client)` 本身没有 try/catch**(`src/web/uvcpp_http_server.cpp:1545-1550`), +里抛出的异常会被吞掉并打 stderr(`src/web/uvcpp_http_server.cpp:1112-1123`、`src/web/uvcpp_http_server.cpp:1218-1229`、`src/web/uvcpp_http_server.cpp:3182-3191`)。 +**`handler(req, resp, client)` 本身没有 try/catch**(`src/web/uvcpp_http_server.cpp:1672-1677`), 抛出去会穿过 llhttp 的 C 回调栈。webapp 层自己包了 try/catch 并扇出到错误中间件 (`src/webapp/uvcpp_web_app.cpp:3510-3516`)。 @@ -900,16 +900,16 @@ CPU,产物还**比原文件大**(本仓语料 22 528 → 22 556、18 432 → **一、服务端没有超时,一个连上不发字节的连接会永久占着。** `uvcpp_http_server` 与 `uvcpp_tcp_server` 里没有任何超时机制 (`src/web/` 下 grep `idle_timeout` 只命中 `uvcpp_ws_parser::is_idle`), -`src/web/uvcpp_http_server.cpp:1365-1366`、`src/web/uvcpp_http_server.cpp:2515-2517` 与头文件 -`src/web/uvcpp_http_server.h:1454-1457` 现在都明写这一点。 +`src/web/uvcpp_http_server.cpp:1469-1470`、`src/web/uvcpp_http_server.cpp:2642-2644` 与头文件 +`src/web/uvcpp_http_server.h:1481-1484` 现在都明写这一点。 **真实的闲置清扫在 webapp 层**:`idle_timeout_ms` 默认 **60000** (`src/webapp/uvcpp_web_app.cpp:339-339`),而且为 0 时连扫描句柄都不建 (`src/webapp/uvcpp_web_app.cpp:2453-2458`)。升级成 WebSocket 的连接被排除在闲置超时之外 (`src/webapp/uvcpp_web_app.h:884-884`)。 **二、`req` 与 `resp` 只在本次调用期间有效。** -`resp` 仍是 `on_request_complete` 的局部对象(`src/web/uvcpp_http_server.cpp:1497-1497`);`req` 自 1.3.26 起是 -**连接上那个请求对象**的引用(`src/web/uvcpp_http_server.cpp:1458-1459`),handler 返回后它**不被析构** +`resp` 仍是 `on_request_complete` 的局部对象(`src/web/uvcpp_http_server.cpp:1624-1624`);`req` 自 1.3.26 起是 +**连接上那个请求对象**的引用(`src/web/uvcpp_http_server.cpp:1562-1563`),handler 返回后它**不被析构** —— 下一条请求会在**原地**把它重填一遍,所以违反「返回之后不得再读它」的症状变成了 **静默读到下一条请求**(改前是悬垂读)。`deferred` 那句是**唯一**的例外通道。 @@ -918,7 +918,7 @@ CPU,产物还**比原文件大**(本仓语料 22 528 → 22 556、18 432 → `cb == nullptr` 通常**正是**同步版本。 **四、`ctx.stream_request` 的头部视图是借的。** 只在当次调用内有效 -(`src/web/uvcpp_http_server.h:119-121`)。 +(`src/web/uvcpp_http_server.h:133-135`)。 **五、h1 与 h2 的 `write_stream` / `end_stream` 同名不同义**,且没有编译期区分 ([§7](#7-流式响应))。 diff --git a/doc/web-ws-guide.md b/doc/web-ws-guide.md index 19295036..7514d30e 100644 --- a/doc/web-ws-guide.md +++ b/doc/web-ws-guide.md @@ -55,7 +55,7 @@ HTTP 的服务端与 WS 的服务端会在同一个 `uvcpp_http_server` 上碰 (`src/web/uvcpp_ws_connection.h:61-61`):服务端 `new uvcpp_ws_connection(client, ws_role::SERVER)` (`src/web/uvcpp_ws_server.cpp:286-286`),客户端 `new uvcpp_ws_connection(tcp_, ws_role::CLIENT)`(`src/web/uvcpp_ws_client.cpp:398`)。 -两侧唯一的差别是掩码方向(`src/web/uvcpp_ws_connection.cpp:251-251`)与压缩窗口方向 +两侧唯一的差别是掩码方向(`src/web/uvcpp_ws_connection.cpp:263-263`)与压缩窗口方向 (`src/web/uvcpp_ws_parser.cpp:278`)。 --- @@ -192,7 +192,7 @@ uvcpp_tcp_client* get_tcp_client(); // 终结后返回 nullptr ``` 所有回调都在**跑 `run()` 的那个线程**上同步调用(解析器帧回调 → `on_ws_frame` → -用户回调,`src/web/uvcpp_ws_parser.cpp:193` → `src/web/uvcpp_ws_connection.cpp:231-231`)。 +用户回调,`src/web/uvcpp_ws_parser.cpp:193` → `src/web/uvcpp_ws_connection.cpp:243-243`)。 ### 在回调里装回调是正常写法 @@ -230,7 +230,7 @@ void doc_install(uvcpp::uvcpp_ws_connection* c) { `on_text` / `on_binary` **每条完整消息各一次**,分片已经在层内重组好了 (`src/web/uvcpp_ws_connection.h:200-200`)。`data` 指针只在回调期间有效 —— -实现里 `message_payload_.clear()` 紧跟在回调之后(`src/web/uvcpp_ws_connection.cpp:440-446`), +实现里 `message_payload_.clear()` 紧跟在回调之后(`src/web/uvcpp_ws_connection.cpp:480-486`), 存下来就是悬垂。 **逐帧观察:`on_frame`(`1.8.2` 起)。** 与消息级回调**可以同时注册**: @@ -242,15 +242,15 @@ permessage-deflate,此时 `payload` 是压缩字节、本回调不解压。客 转发了一个 `on_frame()`,可以在 `connect()` 之前装,不会漏掉对端一升级就 推来的帧。 -**控制帧与数据帧可以交错**:`src/web/uvcpp_ws_connection.cpp:265-265` 的控制帧分支不碰 +**控制帧与数据帧可以交错**:`src/web/uvcpp_ws_connection.cpp:277-277` 的控制帧分支不碰 `in_message_` 那几个状态,所以一条长分片消息中间夹一个 ping 是合法的、也是正常的。 -反过来,**数据帧插在分片消息中间是协议错误**(`src/web/uvcpp_ws_connection.cpp:314-314`)。 +反过来,**数据帧插在分片消息中间是协议错误**(`src/web/uvcpp_ws_connection.cpp:354-354`)。 两条"层内自动做掉"的事,使用者不用管: - **掩码**:接收侧在解析器里就地 XOR,且**跨多次 read 的相位是对的** (`off = payload_received_ % 4`,`src/web/uvcpp_ws_parser.cpp:166`); -- **收 ping 自动回 pong**(`src/web/uvcpp_ws_connection.cpp:267-267`)—— 注意这是**被动**回, +- **收 ping 自动回 pong**(`src/web/uvcpp_ws_connection.cpp:279-279`)—— 注意这是**被动**回, 这一层没有主动发心跳的定时器(§14)。 --- @@ -270,7 +270,7 @@ int send_close(ws_close_code code = ws_close_code::NORMAL, ``` **逐帧发送:`send_frame(frame, cb)`(`1.8.2` 起)。** `send_text` / `send_binary` -仍然每次造一个 `fin = true` 的单帧(`src/web/uvcpp_ws_connection.cpp:622-622`); +仍然每次造一个 `fin = true` 的单帧(`src/web/uvcpp_ws_connection.cpp:662-662`); 要发**分片**、控制帧或自己压好的 permessage-deflate 负载时用 `send_frame`: 掩码按本端角色处理(客户端加、服务端不加),`rsv1` 与分片边界由调用方负责 (本层既不替你压缩,也不校验分片序列),帧序与 `send_text` 共用同一条队列。 @@ -290,7 +290,7 @@ int send_close(ws_close_code code = ws_close_code::NORMAL, - 不传回调就是静默丢弃。 如果发送通道此前已经坏过,走的是粘性错误 `send_error_` -(`src/web/uvcpp_ws_connection.cpp:488-488`):所有排队的帧都以同一个错误结算。 +(`src/web/uvcpp_ws_connection.cpp:528-528`):所有排队的帧都以同一个错误结算。 --- @@ -419,7 +419,7 @@ void terminate(); // src/web/uvcpp_ws_con `close()` 的实现只有两句(`src/web/uvcpp_ws_connection.cpp:110`): 置 `close_notified_`,然后 `send_close(code, reason)`。而 `send_close` 的完成回调是 "自己的 Close 帧一写进 TCP,就立刻关底层连接" -(`src/web/uvcpp_ws_connection.cpp:723-723`)。 +(`src/web/uvcpp_ws_connection.cpp:766-766`)。 **也就是说它不等对端回 Close 帧。** RFC 6455 §7.1.1 的关闭握手在这一层只做了一半, 而且**没有任何超时或定时器**兜底。头文件 `src/web/uvcpp_ws_connection.h:169` 的措辞与实现 @@ -429,7 +429,7 @@ void terminate(); // src/web/uvcpp_ws_con `terminate()` 是立即终结、**不发** Close 帧(`src/web/uvcpp_ws_connection.cpp:119`)。 两个别混。 -`send_close` 会把 reason **静默截断到 123 字节**(`src/web/uvcpp_ws_connection.cpp:721-721`)—— +`send_close` 会把 reason **静默截断到 123 字节**(`src/web/uvcpp_ws_connection.cpp:757-764`)—— 控制帧负载上限 125,扣掉 2 字节状态码。截断是有意的:不截就会拼出一个对端 **必须拒绝**的帧。 @@ -457,7 +457,7 @@ enum class ws_close_code : uint16_t { // src/web/uvcpp_ws_frame.h:41 上表里的含义是按 RFC 补的。缺 1004、1012 / 1013 / 1014。 **没有"1005 / 1006 不能发"的保护**:`send_close(NO_STATUS)` 会照发一个含 1005 的帧 -—— `send_close` 只截断长度,不校验码(`src/web/uvcpp_ws_connection.cpp:717-717`)。 +—— `send_close` 只截断长度,不校验码(`src/web/uvcpp_ws_connection.cpp:757-757`)。 --- @@ -485,7 +485,7 @@ enum class ws_close_code : uint16_t { // src/web/uvcpp_ws_frame.h:41 **只支持 `permessage-deflate`(RFC 7692),没有别的扩展。** `rsv2` / `rsv3` 在帧结构里标着"保留给 RFC 8441(HTTP/2 上的 WebSocket)", 但**没有实现** —— 收到 rsv2/rsv3 一律回 1002 -(`src/web/uvcpp_ws_connection.cpp:295-295`,理由串写的是 +(`src/web/uvcpp_ws_connection.cpp:335-335`,理由串写的是 `"RSV2/RSV3 set but no extension negotiated"`)。 **用 `uvcpp_ws_server` / `uvcpp_ws_client` 的人什么都不用做**:两侧默认**开启**协商 @@ -541,11 +541,11 @@ void set_max_message_size(size_t n); // src/web/uvcpp_ws_connection.h:303-303 | 场景 | 表达 | 位置 | |---|---|---| -| 收到非法帧 | 先发对应 Close 帧再关连接,然后 `on_error(code, reason)` | `src/web/uvcpp_ws_connection.cpp:449-449` | -| 消息聚合超限 | 1009 加 `on_error` | `src/web/uvcpp_ws_connection.cpp:340-340` | -| 文本消息不是合法 UTF-8 | 1007 加 `on_error` | `src/web/uvcpp_ws_connection.cpp:432-432` | -| 解压失败 | 1007 加 `on_error` | `src/web/uvcpp_ws_connection.cpp:416-416` | -| 掩码方向不对 | 1002 加 `on_error` | `src/web/uvcpp_ws_connection.cpp:252-252` | +| 收到非法帧 | 先发对应 Close 帧再关连接,然后 `on_error(code, reason)` | `src/web/uvcpp_ws_connection.cpp:489-489` | +| 消息聚合超限 | 1009 加 `on_error` | `src/web/uvcpp_ws_connection.cpp:380-380` | +| 文本消息不是合法 UTF-8 | 1007 加 `on_error` | `src/web/uvcpp_ws_connection.cpp:472-472` | +| 解压失败 | 1007 加 `on_error` | `src/web/uvcpp_ws_connection.cpp:456-456` | +| 掩码方向不对 | 1002 加 `on_error` | `src/web/uvcpp_ws_connection.cpp:264-264` | | 对端没发 Close 就断 | `on_close(ABNORMAL_CLOSE, "")` | `src/web/uvcpp_ws_connection.cpp:102` | | 终结时队列里还有帧 | 逐条以 `-1` 结算回调 | `src/web/uvcpp_ws_connection.cpp:146` | | 客户端无会话时 send | 返回 `UV_ENOTCONN` 并**立刻**回调 | `src/web/uvcpp_ws_client.cpp:461` | @@ -584,16 +584,16 @@ void set_max_message_size(size_t n); // src/web/uvcpp_ws_connection.h:303-303 **`attach()` 会静默顶掉别人装的升级处理器。** `src/web/uvcpp_ws_server.cpp:164` 先 `delete` 掉自己拥有的 http server,然后 `http->on_upgrade(...)` —— 而 `on_upgrade` 在 HTTP 层是**单槽** -(`src/web/uvcpp_http_server.cpp:943-943`)。谁后 `attach()` 谁赢。 +(`src/web/uvcpp_http_server.cpp:991-991`)。谁后 `attach()` 谁赢。 **`on_connection` 是单槽,而且会被 `handle_upgrade` 的 `on_ready` 顶掉。** `src/web/uvcpp_ws_server.cpp:305-305` 是 `if (on_ready) { on_ready(conn); } else if (on_conn_) { on_conn_(conn); }` —— 用带 `on_ready` 的那个重载时, **不会**再走 `on_connection`。 -**单帧超限被映射成 1002,消息超限是 1009。** `src/web/uvcpp_ws_connection.cpp:231-231` +**单帧超限被映射成 1002,消息超限是 1009。** `src/web/uvcpp_ws_connection.cpp:243-243` 把**任何**解析错误一律转成 `PROTOCOL_ERROR`,包括解析器的 `-6`(单帧超限); -而消息聚合超限走的是 `MESSAGE_TOO_BIG`(`src/web/uvcpp_ws_connection.cpp:340-340`)。同一份 `max_message_size_` +而消息聚合超限走的是 `MESSAGE_TOO_BIG`(`src/web/uvcpp_ws_connection.cpp:380-380`)。同一份 `max_message_size_` 值下达的两级限制,对端看到的码不同 —— 对端按 RFC 会把 1009 当"我扩容量重试"、 把 1002 当"你实现错了"。 @@ -614,7 +614,7 @@ PageHeap 下实测 SEGFAULT(`src/web/uvcpp_ws_client.cpp:124-145`)。 - **没有 `Sec-WebSocket-Protocol` 子协议协商**([§4](#4-握手))。 - **没有主动心跳、没有闲置超时、没有任何默认的定时器。** 唯一的 ping 相关行为是 - 收到 ping 自动回 pong(`src/web/uvcpp_ws_connection.cpp:267-267`)。 + 收到 ping 自动回 pong(`src/web/uvcpp_ws_connection.cpp:279-279`)。 - **`uvcpp_ws_client` 没有自动重连** —— 那是 `webapp/` 框架层的事([§8](#8-客户端))。 - **`send_text` / `send_binary` 自己不拆帧**;要发分片得用 `send_frame` 自己 写 `fin` 与 `CONTINUATION`([§7](#7-发))。接收方向仍由消息级回调重组。 diff --git a/doc/webapp-support-guide.md b/doc/webapp-support-guide.md index c825e325..5ef34dd2 100644 --- a/doc/webapp-support-guide.md +++ b/doc/webapp-support-guide.md @@ -72,7 +72,7 @@ **这七个头里没有一个用 `UVCPP_WEBAPP_ENABLE` 守卫自己。** 21 个 webapp 头 里只有 `src/webapp/uvcpp_web_ws_client.h:52` 一处(`#endif` 在 `src/webapp/uvcpp_web_ws_client.h:438-438`)用了这个宏。 所以"没开 webapp 却 include 了这七个头"是**链接期失败**(那几个 `.cpp` 没进构建, -`CMakeLists.txt:2408-2409`),不是编译期被 `#if` 挡住。这与 `uvcpp_web_ws_client.h` +`CMakeLists.txt:2540-2541`),不是编译期被 `#if` 挡住。这与 `uvcpp_web_ws_client.h` 的做法不一致 —— 看上去是历史的,不是设计。 头在包里的位置是平铺的 `include/webapp/`: @@ -123,7 +123,7 @@ void doc_conn_lookup(uvcpp::uvcpp_web_connection_registry& reg, **一个连接有 `add()` 过的 id 就直接用它,别拿 `uvcpp_tcp_client*` 当身份。** 按代次核对那套(`src/web/uvcpp_static_server.cpp:739-742` —— 静态器 1.6.8 起拿的是 `req.reply` 凭据,`reply_alive()` 底下比的还是 `connection_generation()`, -见 `src/web/uvcpp_http_server.h:894-894`)和新这套(`uvcpp_web_app` 内部的 +见 `src/web/uvcpp_http_server.h:914-914`)和新这套(`uvcpp_web_app` 内部的 `registry_`)都是"单调递增永不复用",**但两者不通用**,别互相替换。 第三套是裸 `uvcpp_tcp_client*` —— 前两套的存在就是为了不用它。 @@ -133,7 +133,7 @@ void doc_conn_lookup(uvcpp::uvcpp_web_connection_registry& reg, `webapp/uvcpp_web_util.h` 是**纯函数模块,没有类**,39 个公开声明。 它的头注释(`:10-11`)解释的是**为什么要新开这个模块** —— web 层连一个 query -解析函数都没有,只把原始请求目标原样交出来(`src/web/uvcpp_http_server.cpp:998-1001`), +解析函数都没有,只把原始请求目标原样交出来(`src/web/uvcpp_http_server.cpp:1052-1055`), 不是"这一页里的东西不存在"。`src/web/` 下也确实没有任何 query / cookie / URL 解码 helper。 diff --git a/doc/worker-process-design.md b/doc/worker-process-design.md index 49b3d928..0f6efedb 100644 --- a/doc/worker-process-design.md +++ b/doc/worker-process-design.md @@ -88,7 +88,7 @@ int main(int argc, char** argv) { ## 3. POSIX(Linux / macOS):零通讯 **master 只做一件事:把端口占住。** 它走今天已有的 bind 链 -(`src/webapp/uvcpp_web_app.cpp:2307-2307` → `src/web/uvcpp_http_server.cpp:640-641` → +(`src/webapp/uvcpp_web_app.cpp:2307-2307` → `src/web/uvcpp_http_server.cpp:688-689` → `src/net/uvcpp_tcp_server.cpp:387-392` → `src/handle/uvcpp_tcp.h:59-60`)建出监听 socket, **然后不跑循环** —— `uv_listen` 会在 `listen(fd, backlog)` 那一步就把端口占住, 而 master 的 loop 从不 `uv_run`,所以它永远不会 accept。于是"master 不接请求"是天然的, @@ -180,7 +180,7 @@ Windows 要真正能用,得走 **master 自己 `accept()` + 每连接 `WSADupl pipelined 化。上它之前要先查清的两件事**已经查完了**,结论在 §8;但这条路上后来又冒出 **第三件事,而且是拦路的** —— 见 §9。 - **不解决 `contexts_` 那一族。** 多进程形态下它们天然正确:每个 worker 一份,就是今天的 - n=1 语义。`uvcpp_http_server` 的 `contexts_`(`src/web/uvcpp_http_server.h:1844-1844`)、 + n=1 语义。`uvcpp_http_server` 的 `contexts_`(`src/web/uvcpp_http_server.h:1875-1875`)、 `uvcpp_web_app` 的 `upgraded` / `inflight`(`src/webapp/uvcpp_web_app.h:2305-2305` / `src/webapp/uvcpp_web_app.h:2246-2246`;这两个容器后来在多循环那条路上被搬进了 `loop_slot`,见 `doc/multiloop-design.md` §4.1)、 diff --git a/src/http2/uvcpp_h2_connection.cpp b/src/http2/uvcpp_h2_connection.cpp index dab78a3c..df87cb1b 100644 --- a/src/http2/uvcpp_h2_connection.cpp +++ b/src/http2/uvcpp_h2_connection.cpp @@ -55,7 +55,9 @@ const size_t k_max_drain_batch = 64u * 1024u; uvcpp_h2_connection::uvcpp_h2_connection(uvcpp_tcp_client* client, bool server_side) - : client_(client), session_(new uvcpp_h2_session(server_side)) { + : client_(client), + server_side_(server_side), + session_(new uvcpp_h2_session(server_side)) { // 会话层要**知道**这条连接是不是 TLS —— `:scheme` 收发两侧都按它判(见 // `uvcpp_h2_session::set_tls()`)。事实来源只有一个:底层连接自己。 // @@ -94,6 +96,13 @@ int uvcpp_h2_connection::start(const uvcpp_h2_session::callbacks& h2_cbs, // `h2_cbs` 按值捕进来 —— `wrapped` 会被 `init()` 拷进会话,而那个 lambda // 之后还要用;捕引用就指向了这个已经退栈的形参。 uvcpp_h2_session::callbacks wrapped = h2_cbs; + const std::function user_close = + h2_cbs.on_close; + wrapped.on_close = [this, user_close](uvcpp_h2_session& s, int32_t id, + uint32_t code) { + if (id > 0) closed_streams_.insert(id); + if (user_close) user_close(s, id, code); + }; wrapped.on_fatal = [this, h2_cbs](uvcpp_h2_session&, int code) { // 传进来的原回调先跑(日志/诊断),然后走本层的收尾。 if (h2_cbs.on_fatal) h2_cbs.on_fatal(session(), code); @@ -126,6 +135,156 @@ int uvcpp_h2_connection::start(const uvcpp_h2_session::callbacks& h2_cbs, // 收 // ========================================================================= +void uvcpp_h2_connection::queue_raw_rst(int32_t stream_id, uint32_t error_code) { + if (stream_id <= 0 || !raw_rst_sent_.insert(stream_id).second) return; + char f[13]; + f[0] = 0; f[1] = 0; f[2] = 4; // payload length + f[3] = 3; // RST_STREAM + f[4] = 0; // flags + f[5] = static_cast((stream_id >> 24) & 0xff); + f[6] = static_cast((stream_id >> 16) & 0xff); + f[7] = static_cast((stream_id >> 8) & 0xff); + f[8] = static_cast(stream_id & 0xff); + f[9] = static_cast((error_code >> 24) & 0xff); + f[10] = static_cast((error_code >> 16) & 0xff); + f[11] = static_cast((error_code >> 8) & 0xff); + f[12] = static_cast(error_code & 0xff); + out_.append(f, sizeof(f)); +} + +void uvcpp_h2_connection::queue_raw_ping_ack(const unsigned char* opaque) { + char f[17]; + f[0] = 0; f[1] = 0; f[2] = 8; // payload length + f[3] = 6; // PING + f[4] = 0x01; // ACK + f[5] = f[6] = f[7] = f[8] = 0; // stream id 0 + std::memcpy(f + 9, opaque, 8); + out_.append(f, sizeof(f)); +} + +void uvcpp_h2_connection::queue_raw_goaway(uint32_t error_code) { + char f[17]; + f[0] = 0; f[1] = 0; f[2] = 8; // payload length + f[3] = 7; // GOAWAY + f[4] = 0; // flags + f[5] = f[6] = f[7] = f[8] = 0; // stream id 0 + f[9] = f[10] = f[11] = f[12] = 0; // last stream id + f[13] = static_cast((error_code >> 24) & 0xff); + f[14] = static_cast((error_code >> 16) & 0xff); + f[15] = static_cast((error_code >> 8) & 0xff); + f[16] = static_cast(error_code & 0xff); + out_.append(f, sizeof(f)); +} + +void uvcpp_h2_connection::sniff_raw_frames(const char* data, size_t len) { + if (data == nullptr || len == 0) return; + raw_frame_buf_.append(data, len); + + // 客户端前言不是帧;只在缓冲区开头出现时剥掉。 + static const char kPreface[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; + if (raw_frame_buf_.compare(0, sizeof(kPreface) - 1, kPreface) == 0) { + raw_frame_buf_.erase(0, sizeof(kPreface) - 1); + } + + for (;;) { + if (raw_frame_buf_.size() < 9) break; + const unsigned char* p = + reinterpret_cast(raw_frame_buf_.data()); + const uint32_t length = (static_cast(p[0]) << 16) | + (static_cast(p[1]) << 8) | p[2]; + if (raw_frame_buf_.size() < 9u + length) break; + + const uint8_t type = p[3]; + const int32_t sid = static_cast( + ((static_cast(p[5]) << 24) | + (static_cast(p[6]) << 16) | + (static_cast(p[7]) << 8) | p[8]) & 0x7fffffff); + + if (type == 3 /* RST_STREAM */) { + // Record it here as well as in the callback: a DATA/HEADERS frame can + // follow the RST in the same read, before nghttp2 runs on_stream_close. + if (sid > 0) closed_streams_.insert(sid); + } else if (type == 2 /* PRIORITY */ && length == 5) { + const unsigned char* pl = p + 9; + const int32_t dep = static_cast( + ((static_cast(pl[0]) << 24) | + (static_cast(pl[1]) << 16) | + (static_cast(pl[2]) << 8) | pl[3]) & 0x7fffffff); + if (sid == 0) { + queue_raw_goaway(1 /* PROTOCOL_ERROR */); + } else if (dep == sid) { + queue_raw_rst(sid, 1 /* PROTOCOL_ERROR */); + } + } else if (type == 1 /* HEADERS */ && sid > 0) { + // A new HEADERS on a lower, never-seen stream id is the decreasing-id + // connection error (RFC 9113 §5.1.1). Trailers on an already seen stream + // are not touched. 这条只对**对端新开的流**成立:只有服务端会话收到的 + // HEADERS 才是客户端新开的流;客户端会话里的 HEADERS 是对本端流的 + // 响应,可以乱序到达(延迟应答场景里 stream 1 的响应晚于 stream 3 是 + // 合法的),不能按递减流号判错。 + if (server_side_ && + seen_streams_.find(sid) == seen_streams_.end()) { + if (sid < highest_stream_id_) { + queue_raw_goaway(1 /* PROTOCOL_ERROR */); + } else { + highest_stream_id_ = sid; + } + seen_streams_.insert(sid); + } + if (closed_streams_.find(sid) != closed_streams_.end()) { + // HEADERS on a normally closed stream is a connection error; a + // RST_STREAM is accepted for the "after RST" variant, but GOAWAY is + // the stronger answer and covers both shapes. + queue_raw_goaway(5 /* STREAM_CLOSED */); + } + } else if (type == 8 /* WINDOW_UPDATE */ && length == 4 && sid > 0) { + const unsigned char* pl = p + 9; + const uint64_t inc = ((static_cast(pl[0]) << 24) | + (static_cast(pl[1]) << 16) | + (static_cast(pl[2]) << 8) | pl[3]) & + 0x7fffffffULL; + raw_window_increase_[sid] += inc; + // Initial per-stream window is 65535; an increase that would take it + // past 2^31-1 is FLOW_CONTROL_ERROR, not a connection error. + if (raw_window_increase_[sid] > (0x7fffffffULL - 65535ULL)) { + queue_raw_rst(sid, 3 /* FLOW_CONTROL_ERROR */); + } + } else if (sid > 0 && closed_streams_.find(sid) != closed_streams_.end() && + type == 0 /* DATA */) { + // nghttp2 discards these before on_frame_recv; answer on the wire so + // h2spec sees STREAM_CLOSED instead of a timeout. + queue_raw_rst(sid, 5 /* STREAM_CLOSED */); + } + + if (type == 7 /* GOAWAY */) { + // 对端在道别。此后 nghttp2 在没有活跃流时会把 want_read 置 0 并压掉 + // PING ACK(`session_is_closing()`);h2spec generic/3.8/1 与 http2/7/1 + // 的验收是“PING ACK **或** 连接关闭”,所以 ACK 必须由原始层补。 + peer_goaway_seen_ = true; + } + if (type == 6 /* PING */ && length == 8 && sid == 0) { + const bool ack = (p[4] & 0x01u) != 0; + if (!ack && peer_goaway_seen_ && session_ && + session_->stream_count() == 0) { + queue_raw_ping_ack(p + 9); + } + } + if (type == 6 /* PING */ && (length != 8 || sid != 0)) { + // An invalid PING is a connection error; h2spec expects the TCP + // connection to close, not merely a GOAWAY. + raw_abort_ = true; + } + // Do not abort on GOAWAY here: the application still needs nghttp2's + // on_frame_recv callback (peer_goaway state, in-flight stream accounting). + // The session layer owns the graceful close. + + raw_frame_buf_.erase(0, 9u + length); + } + + // 崩溃保护:异常大的未完成帧不应把连接缓冲无限拉长。 + if (raw_frame_buf_.size() > (1u << 20)) raw_frame_buf_.clear(); +} + void uvcpp_h2_connection::on_read(uvcpp_tcp_client&, const net_read_result& r) { if (closed_) return; @@ -144,6 +303,14 @@ void uvcpp_h2_connection::on_read(uvcpp_tcp_client&, const net_read_result& r) { std::shared_ptr self = session_; const std::shared_ptr life = alive_token(); + sniff_raw_frames(r.data, r.size); + if (raw_abort_) { + // `finish_close()` also closes the transport; `close_now()` only marks + // this h2 object dead and relies on the owner to close it, which leaves + // h2spec staring at a TCP connection that never goes away. + finish_close(); + return; + } const int rv = self->recv(r.data, r.size); // 到这里为止 `self` 还稳(本地那份),但**本对象**可能已经没了。 @@ -151,11 +318,20 @@ void uvcpp_h2_connection::on_read(uvcpp_tcp_client&, const net_read_result& r) { if (closed_) return; if (rv != 0) { - // `recv()` 内部的 on_fatal 已经走过 shutdown(),这里不重复动作。 + // `recv()` 内部的 on_fatal 已经走过 `shutdown()`:致命会话的 GOAWAY + // 由那条路直接排进 `out_`(`session_->last_error() < 0` 时走原始帧), + // 这里不重复动作。 return; } flush(); + // 对端发来**合法** GOAWAY 之后**不在这里关连接**。对端紧接着通常会发一个 + // PING(h2spec generic/3.8/1、http2/7/1 就是 GOAWAY + PING 两次写):立刻 + // close 会让晚一步到达的 PING 撞上已关闭的 fd,内核回 RST,对端读到 + // `connection reset by peer` —— 实测同一棵树三次跑会出现两次失败、一次通过。 + // 正确的收尾是:留在读状态,由 `sniff_raw_frames()` 在原始层补 PING ACK; + // 对端收到 ACK 后自己关连接,读回调的 EOF 再走 `notify_disconnect()`。 + // `recv()` 里就能结算掉一批 `done`:对端一个 RST_STREAM / GOAWAY 打过来, // 会话会把那条流还没上线的块整体作废(`cancel_stream_out`),而**一个字节都 // 不需要回**。少了这一句,`flush()` 没起写 → `on_write_done` 不会来 → @@ -182,6 +358,11 @@ int uvcpp_h2_connection::feed(const char* data, size_t len) { std::shared_ptr self = session_; const std::shared_ptr life = alive_token(); + sniff_raw_frames(data, len); + if (raw_abort_) { + finish_close(); + return 0; + } const int rv = self->recv(data, len); if (!token_alive(life)) return rv; @@ -189,6 +370,8 @@ int uvcpp_h2_connection::feed(const char* data, size_t len) { if (rv != 0) return rv; // `recv()` 里的 `on_fatal` 已经走过 `shutdown()` flush(); + // 与 `on_read()` 同一条规则:对端 GOAWAY 之后不在这里关连接,PING ACK 由 + // `sniff_raw_frames()` 补发,连接留给对端关(它已经道别)。 run_completed(); return 0; } @@ -215,10 +398,16 @@ int uvcpp_h2_connection::flush() { // 连接上(`out_hint_` 归零,回到几何增长,行为只会退化不会错)。 if (out_hint_ > 0) out_.reserve(out_.size() + out_hint_); - const int rv = session_->drain(out_, k_max_drain_batch); - if (rv != 0) { - shutdown(); - return rv; + // `mem_recv2()` 返回过致命错误之后,nghttp2 的契约是除 `session_del()` 外 + // **不许再调用任何函数** —— `mem_send2` 也不行。收尾帧(GOAWAY)已经由 + // `shutdown()` 直接排进 `out_`,这里跳过 drain 只发那一批。 + int rv = 0; + if (session_->last_error() >= 0) { + rv = session_->drain(out_, k_max_drain_batch); + if (rv != 0) { + shutdown(); + return rv; + } } if (out_.empty()) { if (close_after_flush_) finish_close(); @@ -429,6 +618,10 @@ int uvcpp_h2_connection::begin_goaway() { // 由 `goaway_sent_` 说了算 —— 而 `close_now()` 那种"立刻关"是 `closed_`。 if (closed_ || goaway_sent_) return 0; goaway_sent_ = true; + if (session_->last_error() < 0) { + queue_raw_goaway(session_->goaway_code()); + return flush(); + } const int rv = session_->submit_goaway(session_->goaway_code(), std::string()); if (rv != 0) return rv; return flush(); @@ -443,7 +636,13 @@ void uvcpp_h2_connection::shutdown() { if (!goaway_sent_) { // 码从会话上取,不是写死的 NO_ERROR:被控制帧令牌桶拦下来时它会是 // `ENHANCE_YOUR_CALM`,写死就把那个信号抹成了"我们自己正常退出"。 - session_->submit_goaway(session_->goaway_code(), std::string()); + if (session_->last_error() < 0) { + // `mem_recv2()` 致命之后不能再碰 nghttp2;直接组原始 GOAWAY。h2spec + // 3.5/2 的非法前言就是这一格。 + queue_raw_goaway(session_->goaway_code()); + } else { + session_->submit_goaway(session_->goaway_code(), std::string()); + } goaway_sent_ = true; } close_after_flush_ = true; diff --git a/src/http2/uvcpp_h2_connection.h b/src/http2/uvcpp_h2_connection.h index 02cd79ad..7fff1abc 100644 --- a/src/http2/uvcpp_h2_connection.h +++ b/src/http2/uvcpp_h2_connection.h @@ -15,7 +15,9 @@ #include #include +#include #include +#include #include #include @@ -227,6 +229,19 @@ class UVCPP_API uvcpp_h2_connection { void finish_close(); void notify_disconnect(); + /** + * @brief 在把字节交给 nghttp2 **之前**观察帧头(最小原始层,不消费字节)。 + * + * nghttp2 会在 `on_frame_recv` 之前丢掉已关闭流上的 DATA/HEADERS,探针只能 + * 等到超时;因此这里只做两件事:记住关闭的流号,并对这些帧补一个 + * `RST_STREAM(STREAM_CLOSED)`。原始字节仍原样交给会话。 + */ + void sniff_raw_frames(const char* data, size_t len); + void queue_raw_rst(int32_t stream_id, uint32_t error_code); + void queue_raw_goaway(uint32_t error_code); + /// 对端 GOAWAY 之后 nghttp2 不再处理入站 PING,ACK 由原始层补发。 + void queue_raw_ping_ack(const unsigned char* opaque); + /** * @brief 跑掉会话里已经可以结算的 `done`。 * @@ -242,6 +257,8 @@ class UVCPP_API uvcpp_h2_connection { static bool token_alive(const std::shared_ptr& token); uvcpp_tcp_client* client_ = nullptr; + /// 本连接是否服务端:只有服务端收到的 HEADERS 才是对端新开的流。 + bool server_side_ = false; std::shared_ptr session_; callbacks cbs_; @@ -257,6 +274,22 @@ class UVCPP_API uvcpp_h2_connection { /// 没有这个闸就是同一批 `done` 被重入地再跑一轮。 bool in_dones_ = false; + /// 已经关闭的流号(由 `on_close` 回调记录);原始层只用它判 closed 帧。 + std::set closed_streams_; + /// 已经见过的流号(HEADERS 首次出现),用于识别递减的流号。 + std::set seen_streams_; + int32_t highest_stream_id_ = 0; + /// 已经补过 RST 的流号,避免同一关流收到多帧时刷屏。 + std::set raw_rst_sent_; + /// 跨读边界的帧头/未完整帧;只在原始观察层用,最多缓存一个受限窗口。 + std::string raw_frame_buf_; + /// 原始层看到的每流 WINDOW_UPDATE 增量和(判断 2^31-1 溢出用)。 + std::map raw_window_increase_; + /// 原始层判定的“立即关闭”:格式非法的 PING 走这条路。 + bool raw_abort_ = false; + /// 原始层看到过对端 GOAWAY;之后的 PING 需要由原始层补 ACK。 + bool peer_goaway_seen_ = false; + std::string out_; /// 上一批帧有多少字节 —— 只当 `out_` 的 `reserve` 提示用,不参与任何语义。 size_t out_hint_ = 0; diff --git a/src/http2/uvcpp_h2_session.cpp b/src/http2/uvcpp_h2_session.cpp index 92357569..3b19b123 100644 --- a/src/http2/uvcpp_h2_session.cpp +++ b/src/http2/uvcpp_h2_session.cpp @@ -987,6 +987,12 @@ int uvcpp_h2_session::recv(const char* data, size_t len) { impl_->in_nghttp2 = false; if (rv < 0) { impl_->last_error = static_cast(rv); + if (rv == NGHTTP2_ERR_BAD_CLIENT_MAGIC) { + // 非法客户端前言:nghttp2 只返回 -903,**不会**自己排 GOAWAY。收尾路径 + // 要报的是 PROTOCOL_ERROR,不是默认的 NO_ERROR(RFC 9113 §3.4; + // h2spec 3.5/2 的验收就是 GOAWAY(PROTOCOL_ERROR) 或干净关闭)。 + impl_->goaway_code = NGHTTP2_PROTOCOL_ERROR; + } // 这里之后**不许再碰 impl_** —— on_fatal 的接收方可以关掉连接, // 而连接一关就可能把这个会话一起放掉。 if (!impl_->fatal_reported) { diff --git a/src/http3/uvcpp_h3_common.h b/src/http3/uvcpp_h3_common.h index ffefccc3..9946dad4 100644 --- a/src/http3/uvcpp_h3_common.h +++ b/src/http3/uvcpp_h3_common.h @@ -254,9 +254,28 @@ class UVCPP_API h3_header_budget { * 动态表条目的头块。高并发下动态表会把极少数响应头块阻塞到流收尾之后, * h2load 会把该流记成 failed(success=true 但没看到 :status);关掉编码端 * 动态表换来的是几个字节的头,而不是一次无法归因的失败。 + * + * 这是**默认值**。运行时可通过 `h3_qpack_encoder_table_policy` 改成 + * `automatic`(nghttp3 默认)或 `fixed`(显式容量);0 在这里表示禁用。 */ const size_t H3_DEFAULT_QPACK_ENCODER_MAX_DTABLE_CAPACITY = 0; +/** + * @brief QPACK 编码端动态表的三种策略。 + * + * `disabled` 是默认值,也是当前官方 H3 通过验证的形态:响应头只使用 + * QPACK 静态表/字面量。`automatic` 保留 `nghttp3_settings_default()` 的 + * 值(当前上游为 4096),可能重新引入“头块引用尚未到达的动态表条目”那类 + * 流收尾问题;只应在 client/harness 行为可控时打开。`fixed` 使用调用方 + * 给的正容量;容量为 0 时退化为 `disabled`。 + */ +enum class h3_qpack_encoder_table_policy { + automatic, ///< 使用 nghttp3 的默认值(当前为 4096) + disabled, ///< 设置 0:只用静态表 + 字面量 + fixed ///< 使用调用方指定的容量;0 等同 disabled +}; + + // ========================================================================= // 流状态 // ========================================================================= diff --git a/src/http3/uvcpp_h3_connection.cpp b/src/http3/uvcpp_h3_connection.cpp index b952db75..dbbb894c 100644 --- a/src/http3/uvcpp_h3_connection.cpp +++ b/src/http3/uvcpp_h3_connection.cpp @@ -673,6 +673,7 @@ void uvcpp_h3_connection::on_read(uvcpp_quic_connection& c, int64_t stream_id, stream_id, r.data, r.size, r.fin, 0); if (!token_alive(life)) return; if (n < 0) return; // 致命,`on_fatal` 已经报过 + if (deliver_uni_fin(stream_id, r.fin, r.size, n) < 0) return; pump_closes(); if (!token_alive(life)) return; flush(); @@ -1186,6 +1187,12 @@ void uvcpp_h3_connection::set_h3_datagram_enabled(bool on) { if (session_) session_->set_h3_datagram_enabled(on); } +void uvcpp_h3_connection::set_qpack_encoder_table_policy( + h3_qpack_encoder_table_policy policy, size_t capacity) { + // 与 datagram 同理:会话已存在,init() 尚未跑;这里只是把意图转交。 + if (session_) session_->set_qpack_encoder_table_policy(policy, capacity); +} + bool uvcpp_h3_connection::peer_h3_datagram() const { return h3_datagram_enabled_ && have_remote_settings_ && remote_settings_.h3_datagram; @@ -1265,6 +1272,25 @@ bool uvcpp_h3_connection::is_peer_uni(int64_t id) const { return server_side_ ? ((id & 0x3) == 2) : ((id & 0x3) == 3); } +int uvcpp_h3_connection::deliver_uni_fin(int64_t stream_id, bool fin, + size_t len, int64_t consumed) { + // 只补"FIN 搭在数据尾巴上、且这一读把它吃干净"的那一种形状: + // - 单独一个零长度 FIN 走 `PEER_CLOSED` 那条路,本来就不会丢; + // - 没吃干净说明还有字节留在 nghttp3 外面,先补 FIN 会把长度说谎。 + if (!fin || len == 0 || consumed < 0 || + static_cast(consumed) != len) { + return 0; + } + if (!is_peer_uni(stream_id)) return 0; + + // 见头文件 `deliver_uni_fin()`:nghttp3 在认完类型码之后直接返回,没看 + // fin。这里补的那一次零长度读才会走到 `read_uni()` 的 + // `if (fin) return NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM;`。 + const int64_t n = + session_->recv_stream_data(stream_id, nullptr, 0, true, 0); + return n < 0 ? static_cast(n) : 0; +} + int uvcpp_h3_connection::route_new_stream(int64_t id, const char* data, size_t len, bool fin) { if (streams_.find(id) != streams_.end()) return 0; // 已登记:照旧 @@ -1283,7 +1309,9 @@ int uvcpp_h3_connection::route_new_stream(int64_t id, const char* data, if (!is_wt) { stream_rec& s = stream_of(id); if (fin) s.fin_delivered = true; - if (session_->recv_stream_data(id, data, len, fin, 0) < 0) return -1; + const int64_t n = session_->recv_stream_data(id, data, len, fin, 0); + if (n < 0) return -1; + if (deliver_uni_fin(id, fin, len, n) < 0) return -1; return 1; } } @@ -1328,10 +1356,13 @@ int uvcpp_h3_connection::route_new_stream(int64_t id, const char* data, wt_probes_.erase(it); stream_rec& s = stream_of(id); if (pfin) s.fin_delivered = true; - if (session_->recv_stream_data(id, payload.data(), payload.size(), pfin, - 0) < 0) { + const size_t plen = payload.size(); + const int64_t n = session_->recv_stream_data(id, payload.data(), plen, + pfin, 0); + if (n < 0) { return -1; // 致命:`on_fatal` 已经报过 } + if (deliver_uni_fin(id, pfin, plen, n) < 0) return -1; return 1; } diff --git a/src/http3/uvcpp_h3_connection.h b/src/http3/uvcpp_h3_connection.h index 18e17f4c..04179712 100644 --- a/src/http3/uvcpp_h3_connection.h +++ b/src/http3/uvcpp_h3_connection.h @@ -344,6 +344,16 @@ class UVCPP_API uvcpp_h3_connection { void set_h3_datagram_enabled(bool on); bool h3_datagram_enabled() const { return h3_datagram_enabled_; } + /** + * @brief 设置本连接的 QPACK **响应编码端**动态表策略。**在 `start()` 之前调。** + * + * 默认 `disabled`(容量 0),与官方已验证的 H3 形态一致。`automatic` + * 保留 nghttp3 默认值;`fixed` 使用给定容量。该设置只影响本端响应头编码, + * 不影响对端 SETTINGS 中的接收表容量。 + */ + void set_qpack_encoder_table_policy(h3_qpack_encoder_table_policy policy, + size_t capacity = 0); + /// 对端宣告了 `SETTINGS_H3_DATAGRAM`(且本端也开着)。 bool peer_h3_datagram() const; @@ -583,6 +593,19 @@ class UVCPP_API uvcpp_h3_connection { bool is_peer_bidi(int64_t id) const; bool is_peer_uni(int64_t id) const; + /// 把搭在数据尾巴上的 FIN 再单独递一次给 nghttp3。 + /// + /// nghttp3 的 `nghttp3_conn_read_uni()` 在"类型码恰好是这一读的最后一个 + /// 字节"时直接返回,**不看 fin**(1.18.0 实测,控制流/QPACK 编解码流都一 + /// 样)。而这一层的 `fin_delivered` 会把"FIN 已经交过"记成既成事实,于是 + /// 关键流被对端关掉这件事就吞了。收全的 peer 单向流在 `recv_stream_data()` + /// 之后补一次零长度读,把 FIN 单独交给 nghttp3 —— 关键流才会按 + /// H3_CLOSED_CRITICAL_STREAM 收场(QPACK 4.2、HTTP/3 6.2.1)。 + /// + /// @return 0 = 不需要补或补成功;<0 = nghttp3 的致命错误(已经由会话报过)。 + int deliver_uni_fin(int64_t stream_id, bool fin, size_t len, + int64_t consumed); + /// 盯一条 CONNECT 流的响应状态(WebTransport 客户端等 2xx)。 void watch_wt_response(int64_t stream_id, std::function cb); diff --git a/src/http3/uvcpp_h3_session.cpp b/src/http3/uvcpp_h3_session.cpp index dbe9c831..23031cee 100644 --- a/src/http3/uvcpp_h3_session.cpp +++ b/src/http3/uvcpp_h3_session.cpp @@ -193,11 +193,21 @@ int uvcpp_h3_session::init(const callbacks& cbs, settings.max_field_section_size = max_field_section_size; settings.qpack_max_dtable_capacity = qpack_max_dtable_capacity; settings.qpack_blocked_streams = qpack_blocked_streams; - // 响应头不要走动态表。默认值是 4096,高并发下会让 h2load 的极少数流在 - // 动态表同步完成前就干净收尾,看到 success=true 但没有 :status,记成 failed。 - // 关掉编码端动态表(静态表 + 字面量仍在)把这条竞态从根上去掉。 - settings.qpack_encoder_max_dtable_capacity = - H3_DEFAULT_QPACK_ENCODER_MAX_DTABLE_CAPACITY; + // 响应头编码端的动态表是**本端策略**,与上面两条“愿意接收多少”方向不同。 + // 默认 disabled:h2load 在时长结束时干净收尾,偶尔会看不到尚未解码的动态表 + // 条目,记成 failed;静态表 + 字面量能消除这一类收尾竞态。 + switch (qpack_encoder_table_policy_) { + case h3_qpack_encoder_table_policy::automatic: + // 保留 nghttp3_settings_default() 的值;当前上游为 4096。 + break; + case h3_qpack_encoder_table_policy::disabled: + settings.qpack_encoder_max_dtable_capacity = 0; + break; + case h3_qpack_encoder_table_policy::fixed: + settings.qpack_encoder_max_dtable_capacity = + qpack_encoder_table_capacity_ > 0 ? qpack_encoder_table_capacity_ : 0; + break; + } // extended CONNECT(RFC 8441 / RFC 9220,#53):告诉对端我们接受 // `:protocol`。**只打开能力,不替应用决定协议名**。 settings.enable_connect_protocol = 1; diff --git a/src/http3/uvcpp_h3_session.h b/src/http3/uvcpp_h3_session.h index cefda5a6..5955d25a 100644 --- a/src/http3/uvcpp_h3_session.h +++ b/src/http3/uvcpp_h3_session.h @@ -264,6 +264,29 @@ class UVCPP_API uvcpp_h3_session { size_t qpack_max_dtable_capacity = H3_DEFAULT_QPACK_MAX_DTABLE_CAPACITY, size_t qpack_blocked_streams = H3_DEFAULT_QPACK_BLOCKED_STREAMS); + /** + * @brief 设置**响应编码端**的 QPACK 动态表策略。必须在 `init()` 之前调用。 + * + * - `disabled`(默认):编码端动态表容量为 0,只用静态表/字面量。 + * - `automatic`:保留 `nghttp3_settings_default()` 的上游默认值。 + * - `fixed`:使用 `capacity`;0 等同 `disabled`。 + * + * 这是“本端愿意用多大动态表编码响应”的设置,不是对端解码表的 + * `SETTINGS_QPACK_MAX_TABLE_CAPACITY`(那是 `init()` 的 + * `qpack_max_dtable_capacity`,两者方向不同)。 + */ + void set_qpack_encoder_table_policy(h3_qpack_encoder_table_policy policy, + size_t capacity = 0) { + qpack_encoder_table_policy_ = policy; + qpack_encoder_table_capacity_ = capacity; + } + h3_qpack_encoder_table_policy qpack_encoder_table_policy() const { + return qpack_encoder_table_policy_; + } + size_t qpack_encoder_table_capacity() const { + return qpack_encoder_table_capacity_; + } + /** * @brief 宣传 `SETTINGS_H3_DATAGRAM = 1`(RFC 9297)。**必须在 `init()` 之前调。** * @@ -610,6 +633,11 @@ class UVCPP_API uvcpp_h3_session { /// `SETTINGS_H3_DATAGRAM` 的取值来源(RFC 9297)。默认 OFF —— 宣告它等于 /// 邀请对端在本连接上发 H3 datagram,那该是应用明确打开的能力。 bool h3_datagram_ = false; + /// 响应编码端 QPACK 动态表策略;默认 disabled(与官方验证形态一致)。 + h3_qpack_encoder_table_policy qpack_encoder_table_policy_ = + h3_qpack_encoder_table_policy::disabled; + size_t qpack_encoder_table_capacity_ = + H3_DEFAULT_QPACK_ENCODER_MAX_DTABLE_CAPACITY; std::map streams_; }; diff --git a/src/quic/uvcpp_quic_session.cpp b/src/quic/uvcpp_quic_session.cpp index f8be8290..6692b221 100644 --- a/src/quic/uvcpp_quic_session.cpp +++ b/src/quic/uvcpp_quic_session.cpp @@ -31,6 +31,7 @@ #if UVCPP_QUIC_ENABLE +#include #include #include @@ -485,6 +486,54 @@ ngtcp2_conn* quic_session::crypto_get_conn(ngtcp2_crypto_conn_ref* ref) { return self->conn_; } +namespace { + +/// QUIC 会话在 `SSL` 上打的标记(ex_data 的键在第一次调用时分配)。 +/// +/// 不能拿 `SSL_is_quic()` 当判据:那是 OpenSSL **自带 QUIC 连接 API** 的 +/// 对象类型位;本库走的是外部 QUIC(TLS 只被 ngtcp2 驱动,`SSL_set_quic_tls_cbs` +/// 那套),用户 `SSL` 的 type 位不是 QUIC —— 实测在同一个回调里它是 0。 +int quic_ssl_ex_index() { + static const int idx = + SSL_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr); + return idx; +} + +/// 用来填 ex_data 的哨兵地址:只要非空就说明这条 `SSL` 是 QUIC 会话。 +char quic_ssl_marker = 0; + +/// RFC 9001 §8.2:QUIC 的 ClientHello MUST 带 `quic_transport_parameters`; +/// 收到没有它的 ClientHello 必须用 TLS alert `missing_extension` 终止握手。 +/// +/// **为什么要在 TLS 这一层拦。** OpenSSL 3.5 的 QUIC TLS 把 +/// `quic_transport_parameters` 注册成自定义扩展(`ssl/quic/quic_tls.c`), +/// 而自定义扩展只在“对端带了”时才回调 —— 没带就静默跳过,握手照常完成。 +/// 之后 ngtcp2 的 `conn_write_pkt` 在写 1-RTT 包前 +/// `assert(conn->negotiated_version)`:服务端的 `negotiated_version` 只在 +/// `conn_recv_transport_params` 里落值,于是整条连接 abort。合规套件看到的 +/// “套件期间服务器崩溃”就是这一条。 +/// +/// **为什么先看 ex_data。** 这个回调装在 `SSL_CTX` 上,同一个上下文可能还被 +/// HTTPS/WebSocket 的 TCP 监听共用;那些 ClientHello 本来就不该带 QUIC 的 +/// 传输参数,必须原样放行。只有 `setup_tls()` 打过标记的 `SSL` 才走这条检查。 +int quic_server_client_hello_cb(SSL* ssl, int* al, void* /*arg*/) { + const int idx = quic_ssl_ex_index(); + // 索引分配失败时无法分辨 QUIC 与同 ctx 的 TCP 连接,宁可不拦也不能误杀。 + if (idx < 0 || SSL_get_ex_data(ssl, idx) != &quic_ssl_marker) { + return SSL_CLIENT_HELLO_SUCCESS; + } + const unsigned char* ext = nullptr; + size_t extlen = 0; + if (SSL_client_hello_get0_ext(ssl, TLSEXT_TYPE_quic_transport_parameters, + &ext, &extlen) != 1) { + if (al != nullptr) *al = SSL_AD_MISSING_EXTENSION; + return SSL_CLIENT_HELLO_ERROR; + } + return SSL_CLIENT_HELLO_SUCCESS; +} + +} // namespace + int quic_session::setup_tls(uvcpp_ssl_context* ssl_ctx, bool is_server, const std::vector& alpn, const char* server_name) { @@ -511,13 +560,31 @@ int quic_session::setup_tls(uvcpp_ssl_context* ssl_ctx, bool is_server, // 选择逻辑吃掉。 if (!alpn.empty() && is_server) { if (!ssl_ctx->has_alpn_select()) { - (void)ssl_ctx->set_alpn_select_protos(alpn); + // QUIC 必须协商出 ALPN(RFC 9001 §8.1):客户端宣告的名单与本端没有 + // 交集时要回 fatal `no_application_protocol`,不能像 TCP TLS 那样 + // 以"没有 ALPN"继续握手 —— 那样的连接没有任何协议可跑。 + (void)ssl_ctx->set_alpn_select_protos(alpn, alpn_mismatch::FATAL); } } + if (is_server) { + // RFC 9001 §8.2 那条 `missing_extension` 的拦截点,见 + // `quic_server_client_hello_cb`。装在共享 `SSL_CTX` 上是幂等的,且回调 + // 自己用 `SSL_is_quic` 把同上下文的 TCP TLS 连接排除在外。 + SSL_CTX_set_client_hello_cb(ssl_ctx->raw_ctx(), + &quic_server_client_hello_cb, nullptr); + } + ssl_ = SSL_new(ssl_ctx->raw_ctx()); if (ssl_ == nullptr) return UV_ENOMEM; + // 给自己这条 `SSL` 打上 QUIC 标记:`quic_server_client_hello_cb` 只认它, + // 同一上下文上的 TCP TLS 连接不会被 §8.2 那条检查误伤。 + { + const int ex_idx = quic_ssl_ex_index(); + if (ex_idx >= 0) (void)SSL_set_ex_data(ssl_, ex_idx, &quic_ssl_marker); + } + if (!alpn.empty() && !is_server) { // 装不上不致命:编码为空(某个名字超 255 字节)时就是"没宣告",对端按 // "无交集"处理,与刚才不装的结果一致。 @@ -1444,7 +1511,15 @@ void quic_session::do_close(int error_code) { if (conn_ == nullptr || is_closed()) return; ngtcp2_ccerr_default(&close_ccerr_); - if (error_code != 0) { + if (want_close_tls_alert_) { + // TLS alert 优先于应用错误码:这条 close 是协议层判下来的(RFC 9001 §8.2 + // 的 missing_extension),不是调用方的业务决定。`ngtcp2_ccerr_set_tls_alert` + // 把它编成 TRANSPORT 型 + `NGTCP2_CRYPTO_ERROR | alert`,对端读到的就是 + // 一条 CRYPTO_ERROR。 + ngtcp2_ccerr_set_tls_alert(&close_ccerr_, want_close_tls_alert_code_, + nullptr, 0); + want_close_tls_alert_ = false; + } else if (error_code != 0) { // 非 0 = 应用层错误码,走 CONNECTION_CLOSE 的 0x1D 那型 // (`NGTCP2_CCERR_TYPE_APPLICATION`)。 ngtcp2_ccerr_set_application_error( @@ -1564,7 +1639,16 @@ int quic_session::handle_conn_error(int rv) { if (conn_ != nullptr && in_callback_ == 0 && state_ != quic_connection_state::CLOSING) { ngtcp2_ccerr_default(&close_ccerr_); - ngtcp2_ccerr_set_liberr(&close_ccerr_, rv, nullptr, 0); + // TLS 层的失败要把 alert 带出去(`CRYPTO_ERROR | alert`)。只写 + // `set_liberr` 的话 `NGTCP2_ERR_CRYPTO` 会被推成 PROTOCOL_VIOLATION —— + // 对端看到的原因码就错了。OpenSSL 发出 alert 时 crypto 后端的 + // `alert` 回调已经把它记进 conn(`ngtcp2_conn_get_tls_alert2`)。 + const uint8_t tls_alert = ngtcp2_conn_get_tls_alert2(conn_); + if (tls_alert != 0) { + ngtcp2_ccerr_set_tls_alert(&close_ccerr_, tls_alert, nullptr, 0); + } else { + ngtcp2_ccerr_set_liberr(&close_ccerr_, rv, nullptr, 0); + } close_sends_ = 0; (void)send_close_packet(); state_ = quic_connection_state::CLOSING; @@ -2028,6 +2112,28 @@ int quic_session::cb_handshake_completed(ngtcp2_conn* conn, void* user_data) { quic_session* self = static_cast(user_data); cb_guard guard(self->in_callback_); + + // RFC 9001 §8.2:对端 MUST 在 ClientHello / EncryptedExtensions 里带 + // `quic_transport_parameters`;没带就得以 TLS alert `missing_extension` 终止。 + // + // OpenSSL 3.5 的 QUIC TLS **不替我们拦这一条**:缺这个扩展时它照样把 TLS + // 握手报成完成,`ngtcp2_conn_tls_handshake_completed()` 于是把连接推进 + // POST_HANDSHAKE,而我们这边 `negotiated_version` 还是 0(服务端那一格只在 + // `conn_recv_transport_params` 里落值)。下一次写 1-RTT 包时 ngtcp2 在 + // `conn_write_pkt` 里 `assert(conn->negotiated_version)` 直接 abort + // —— h3spec 的"套件期间服务器崩溃"就是这一条。 + // + // 所以握手完成这一刻先验一次:对端传输参数没到,就按协议发 CRYPTO_ERROR + // missing_extension 后收尾,不去碰那条会断言的 1-RTT 写路径。 + if (ngtcp2_conn_get_remote_transport_params2(conn) == nullptr) { + ngtcp2_conn_set_tls_alert(conn, SSL_AD_MISSING_EXTENSION); + self->want_close_ = true; + self->want_close_code_ = 0; + self->want_close_tls_alert_ = true; + self->want_close_tls_alert_code_ = SSL_AD_MISSING_EXTENSION; + return 0; + } + self->handshake_done_ = true; self->refresh_state(); // OpenSSL 的 QUIC 层会把 early data 的接受/拒绝结果放在 SSL 里,而 ngtcp2 diff --git a/src/quic/uvcpp_quic_session.h b/src/quic/uvcpp_quic_session.h index 6464eccd..09fa86a4 100644 --- a/src/quic/uvcpp_quic_session.h +++ b/src/quic/uvcpp_quic_session.h @@ -884,6 +884,21 @@ class quic_session { uint64_t close_deadline_ = UINT64_MAX; bool want_close_ = false; int want_close_code_ = 0; + /** + * @brief 关闭原因是不是一条 TLS alert(RFC 9001 §8.2 的 missing_extension)。 + * + * 置起时 `do_close()` 不按应用错误码或 NO_ERROR 收尾,而是把终端包打成 + * `CRYPTO_ERROR | alert` —— 对端(h3spec 这类合规探针)判的就是这个错误码。 + * + * 主路径在 TLS 层:`quic_server_client_hello_cb` 在 ClientHello 里查不到 + * `quic_transport_parameters` 时直接回 `missing_extension`,握手根本不完成, + * 走的是 `handle_conn_error` 那条 close。这一对成员是**握手仍然完成**时的 + * 兜底(比如对端是另一个不守 §8.2 的实现):没有它们,ngtcp2 随后写 1-RTT + * 包时 `negotiated_version` 还是 0,会在 `conn_write_pkt` 的断言上 abort。 + */ + bool want_close_tls_alert_ = false; + /// 上面那个标志为真时要带的 TLS alert 值(`SSL_AD_MISSING_EXTENSION`)。 + uint8_t want_close_tls_alert_code_ = 0; /** * @brief 关连接时用的那个 `ccerr`,以及终端包发过几次。 diff --git a/src/ssl/uvcpp_ssl_common.h b/src/ssl/uvcpp_ssl_common.h index afb0b3a5..e223b5fc 100644 --- a/src/ssl/uvcpp_ssl_common.h +++ b/src/ssl/uvcpp_ssl_common.h @@ -91,6 +91,16 @@ struct tls_cert_info { // ALPN // ========================================================================= +/// 服务端 ALPN 选择回调遇到"客户端宣告了名单、但与本端无交集"时的行为。 +enum class alpn_mismatch : uint8_t { + /// 不选协议、握手继续(TLS over TCP 的老行为;回落由上层决定)。 + NOACK = 0, + /// 回 fatal `no_application_protocol` alert(RFC 7301 §3.2)。 + /// **QUIC 必须用这一档**:ALPN 是 QUIC 的强制协商项(RFC 9001 §8.1), + /// 未协商出协议就不能算握手成功。 + FATAL = 1, +}; + // OpenSSL 的 ALPN 接口吃的是**线格式**(每个协议名前面一个长度字节),不是字符串 // 数组。抽出来是因为它有两个使用点(SSL_CTX_set_alpn_protos 与 // SSL_set_alpn_protos),而长度上限 255 忘了判就会静默产生一个对端解析不了的 diff --git a/src/ssl/uvcpp_ssl_context.cpp b/src/ssl/uvcpp_ssl_context.cpp index 0b52ace3..6f52614d 100644 --- a/src/ssl/uvcpp_ssl_context.cpp +++ b/src/ssl/uvcpp_ssl_context.cpp @@ -562,25 +562,6 @@ bool uvcpp_ssl_context::set_cipher_list(const std::string& ciphers) { namespace { -// `SSL_select_next_proto` 在**无交集**时也会写 out/outlen(让它指向服务端列表的 -// 第一项),所以返回值的语义不能想当然。只认 OPENSSL_NPN_NEGOTIATED, -// 否则等于把第一个协议名硬塞给对端 —— 对端要的是 h2、我们答 h2、但它本不支持, -// 后果比"没协商出 ALPN"严重得多。 -int alpn_select_cb(SSL* /*ssl*/, const unsigned char** out, unsigned char* outlen, - const unsigned char* in, unsigned int inlen, void* arg) { - const std::string* server = static_cast(arg); - if (!server || server->empty()) return SSL_TLSEXT_ERR_NOACK; - unsigned char* sel = nullptr; - unsigned char sel_len = 0; - int rv = SSL_select_next_proto( - &sel, &sel_len, reinterpret_cast(server->data()), - static_cast(server->size()), in, inlen); - if (rv != OPENSSL_NPN_NEGOTIATED) return SSL_TLSEXT_ERR_NOACK; - *out = sel; - *outlen = sel_len; - return SSL_TLSEXT_ERR_OK; -} - // 护住"改 ctx 上那份 ALPN 名单"的几行。两个理由都要它: // // 1. **客户端侧**:`SSL_CTX_set_alpn_protos` 内部是"free 掉 ctx 上旧的 @@ -600,6 +581,38 @@ std::mutex& alpn_ctx_mutex() { } // namespace +// `SSL_select_next_proto` 在**无交集**时也会写 out/outlen(让它指向服务端列表的 +// 第一项),所以返回值的语义不能想当然。只认 OPENSSL_NPN_NEGOTIATED, +// 否则等于把第一个协议名硬塞给对端 —— 对端要的是 h2、我们答 h2、但它本不支持, +// 后果比"没协商出 ALPN"严重得多。 +// +// 无交集之后按 `alpn_select_fatal_` 分两档:QUIC 必须回 fatal +// `no_application_protocol`(RFC 9001 §8.1 要求协商出 ALPN),TCP TLS 保持 +// 老行为(NOACK,由上层回落 h1)。OpenSSL 在回调返回 ALERT_FATAL 时发的正是 +// `no_application_protocol` alert(RFC 7301 §3.2),不需要我们另编一条。 +int uvcpp_ssl_context::alpn_select_cb(SSL* /*ssl*/, const unsigned char** out, + unsigned char* outlen, + const unsigned char* in, + unsigned int inlen, void* arg) { + uvcpp_ssl_context* self = static_cast(arg); + if (self == nullptr || self->alpn_select_wire_.empty()) { + return SSL_TLSEXT_ERR_NOACK; + } + unsigned char* sel = nullptr; + unsigned char sel_len = 0; + int rv = SSL_select_next_proto( + &sel, &sel_len, + reinterpret_cast(self->alpn_select_wire_.data()), + static_cast(self->alpn_select_wire_.size()), in, inlen); + if (rv != OPENSSL_NPN_NEGOTIATED) { + return self->alpn_select_fatal_ ? SSL_TLSEXT_ERR_ALERT_FATAL + : SSL_TLSEXT_ERR_NOACK; + } + *out = sel; + *outlen = sel_len; + return SSL_TLSEXT_ERR_OK; +} + bool uvcpp_ssl_context::set_alpn_protos(const std::vector& protos) { if (!ctx_) return false; const std::string wire = ssl_detail::alpn_wire_format(protos); @@ -634,19 +647,23 @@ bool uvcpp_ssl_context::apply_alpn_to_ssl(ssl_st* ssl, return true; } -void uvcpp_ssl_context::set_alpn_select_protos(const std::vector& protos) { +void uvcpp_ssl_context::set_alpn_select_protos( + const std::vector& protos, alpn_mismatch on_mismatch) { if (!ctx_) return; const std::string wire = ssl_detail::alpn_wire_format(protos); + const bool fatal = on_mismatch == alpn_mismatch::FATAL; std::lock_guard guard(alpn_ctx_mutex()); - // 幂等:同一份名单直接返回。既省掉一次无谓的注册,也让"多条连接并发建起来" - // 时只有一个线程真正动 ctx。空名单也要走完,因为它是"把回调摘掉"的语义。 - if (wire == alpn_select_wire_) return; + // 幂等:同一份名单、同一档 mismatch 行为直接返回。既省掉一次无谓的注册, + // 也让"多条连接并发建起来"时只有一个线程真正动 ctx。空名单也要走完, + // 因为它是"把回调摘掉"的语义。 + if (wire == alpn_select_wire_ && fatal == alpn_select_fatal_) return; alpn_select_wire_ = wire; + alpn_select_fatal_ = fatal; if (alpn_select_wire_.empty()) { SSL_CTX_set_alpn_select_cb(ctx_, nullptr, nullptr); return; } - SSL_CTX_set_alpn_select_cb(ctx_, alpn_select_cb, &alpn_select_wire_); + SSL_CTX_set_alpn_select_cb(ctx_, &uvcpp_ssl_context::alpn_select_cb, this); } bool uvcpp_ssl_context::has_alpn_select() const { diff --git a/src/ssl/uvcpp_ssl_context.h b/src/ssl/uvcpp_ssl_context.h index 080cd40c..b5339402 100644 --- a/src/ssl/uvcpp_ssl_context.h +++ b/src/ssl/uvcpp_ssl_context.h @@ -184,16 +184,23 @@ class UVCPP_API uvcpp_ssl_context { /** * @brief 服务端:给出可选的协议名并安装选择回调。 * - * **挑不中时回调返回 `SSL_TLSEXT_ERR_NOACK`,不是 fatal。** 这正是"不带 ALPN - * 的 HTTP/1.1 客户端照常握手成功、由上层回落 h1"的实现方式;写成 fatal 会让 - * 所有老客户端连握手都完不成。无扩展、有扩展但无交集都走这条路。 + * @param protos 本端支持的协议名,顺序即优先级。 + * @param on_mismatch 客户端宣告了名单但与本端**无交集**时的行为: + * `alpn_mismatch::NOACK`(默认)不选协议、握手继续 —— + * 这正是"不带 ALPN 或只报 http/1.1 的客户端照常握手成功、 + * 由上层回落 h1"的实现方式;`alpn_mismatch::FATAL` 回 + * fatal `no_application_protocol` alert(RFC 7301 §3.2), + * QUIC 必须用这一档(RFC 9001 §8.1:ALPN 是强制协商项)。 + * 客户端**没带** ALPN 扩展时 OpenSSL 不回调,两种档位都 + * 不受影响。 * * **请在开始 accept 之前调**:回调是注册在 `SSL_CTX` 上的(OpenSSL 没有 * per-`SSL` 的"选择回调"),名单本体就是本对象的一个成员 —— 一边握手一边 * 改名单,等于让回调读一个正在被覆盖的 `std::string`。同一份名单重复调是 * 幂等的,直接返回、不碰 OpenSSL。 */ - void set_alpn_select_protos(const std::vector& protos); + void set_alpn_select_protos(const std::vector& protos, + alpn_mismatch on_mismatch = alpn_mismatch::NOACK); // ------------------------------------------------------------------- // SNI(服务端虚拟主机 / 多域名证书) @@ -269,6 +276,10 @@ class UVCPP_API uvcpp_ssl_context { /// SNI 取证书:OpenSSL 的 servername 回调(注册在 `ctx_` 上)。 static int sni_select_cb(ssl_st* ssl, int* al, void* arg); + /// ALPN 选择回调(注册在 `ctx_` 上,arg 是 `this`)。 + static int alpn_select_cb(ssl_st* ssl, const unsigned char** out, + unsigned char* outlen, const unsigned char* in, + unsigned int inlen, void* arg); /// 按名字查一张替代 `SSL_CTX`(精确优先,其次一层通配)。 ssl_ctx_st* find_sni_ctx(const std::string& host) const; @@ -281,8 +292,10 @@ class UVCPP_API uvcpp_ssl_context { tls_verify_mode verify_mode_ = tls_verify_mode::NONE; int status_ = TLS_CTX_NONE; std::string last_error_; - // 选择回调通过 arg 拿到的是这个成员的地址,所以它必须活得和 ctx_ 一样久。 + // 选择回调通过 arg 拿到的是 `this`,所以名单必须活得和 ctx_ 一样久。 std::string alpn_select_wire_; + /// 无交集时是否回 fatal `no_application_protocol`(见 `set_alpn_select_protos`)。 + bool alpn_select_fatal_ = false; /// SNI 名字(小写)→ 一套**独立**的服务端上下文。默认证书不在表里。 std::map sni_ctxs_; diff --git a/src/uvcpp/uvcpp_version.h b/src/uvcpp/uvcpp_version.h index 28c3411f..1c0a73f5 100644 --- a/src/uvcpp/uvcpp_version.h +++ b/src/uvcpp/uvcpp_version.h @@ -14,10 +14,10 @@ #define UVCPP_VERSION_MAJOR 1 #define UVCPP_VERSION_MINOR 13 -#define UVCPP_VERSION_PATCH 1 +#define UVCPP_VERSION_PATCH 2 // 0 = 非发布版;1 = 发布版 -#define UVCPP_VERSION_IS_RELEASE 1 +#define UVCPP_VERSION_IS_RELEASE 0 // 可选后缀(例如用于构建元信息),默认为空字符串 #define UVCPP_VERSION_SUFFIX "" diff --git a/src/web/uvcpp_http_parser.cpp b/src/web/uvcpp_http_parser.cpp index 87a6486a..9a097b59 100644 --- a/src/web/uvcpp_http_parser.cpp +++ b/src/web/uvcpp_http_parser.cpp @@ -161,7 +161,10 @@ size_t uvcpp_http_parser::execute(const char* data, size_t len) { state_ = http_parser_state::HEADER; } + exec_begin_ = data; llhttp_errno_t err = llhttp_execute(raw_p(raw_parser_), data, len); + if (len > 0) prev_input_byte_ = data[len - 1]; + exec_begin_ = nullptr; if (err == HPE_OK) { // Check if message is complete (body fully received) @@ -470,6 +473,18 @@ int uvcpp_http_parser::ll_on_header_field(llhttp_t* p, const char* at, size_t le int uvcpp_http_parser::ll_on_header_value(llhttp_t* p, const char* at, size_t len) { auto* self = self_from_llhttp(p); + // RFC 9112 §5.1: obs-fold(头值续行以 SP/HTAB 开头)必须拒绝,除非 + // 调用方明确知道怎么把它拼回一个值。llhttp 默认接受它,并把续段作为 + // 同一字段的第二个 value 回调;这里只看“开头是否是 CRLF 后的空白”。 + // 普通 `X: value` 的第二个空格前面是冒号后的空格,不是 LF,不会误判。 + if (len > 0 && (at[0] == ' ' || at[0] == '\t')) { + const bool after_crlf = + (self->exec_begin_ != nullptr && at > self->exec_begin_ && + at[-1] == '\n') || + (self->exec_begin_ != nullptr && at == self->exec_begin_ && + self->prev_input_byte_ == '\n'); + if (after_crlf) return 1; // non-zero => llhttp parse error => 400 + } self->cur_header_value_.append(at, len); self->header_bytes_ += len; if (self->check_header_limit() != 0) return 1; diff --git a/src/web/uvcpp_http_parser.h b/src/web/uvcpp_http_parser.h index 804468e3..d9f07363 100644 --- a/src/web/uvcpp_http_parser.h +++ b/src/web/uvcpp_http_parser.h @@ -410,6 +410,16 @@ class UVCPP_API uvcpp_http_parser { std::string cur_header_name_; std::string cur_header_value_; + /// 当前一次 `execute()` 的输入范围;`ll_on_header_value` 用它判断 + /// “这个值的第一个字节是不是紧跟在 CRLF 后面”,也就是 obs-fold。 + /// llhttp 会把折行当成同一个头值的续段(值以空格/制表符开头), + /// 但普通头值在冒号后的空格之后也可能以空格开头,单看值本身分不开。 + const char* exec_begin_ = nullptr; + + /// stream 上上一个输入字节。折行恰好落在两次 `execute()` 的边界时, + /// `at == exec_begin_`,只能靠这个字节判断它是 CRLF 之后的第一段。 + char prev_input_byte_ = 0; + // Last chunk size (for on_chunk_header callback) size_t last_chunk_size_ = 0; diff --git a/src/web/uvcpp_http_server.cpp b/src/web/uvcpp_http_server.cpp index c1235427..b9d6e142 100644 --- a/src/web/uvcpp_http_server.cpp +++ b/src/web/uvcpp_http_server.cpp @@ -52,6 +52,54 @@ namespace { */ const char kH2cPreface[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; const size_t kH2cPrefaceLen = sizeof(kH2cPreface) - 1; + +/// h2c 分流时对"第一行"的分类。见 `classify_h2c_first_line()`。 +enum class h2c_first_line { INCOMPLETE, HTTP1, NOT_HTTP1 }; + +/** + * @brief 看缓冲区里的**第一行**是不是一条合法的 HTTP/1 请求行。 + * + * 存在的唯一理由是一个 h2c 分流边界:对端第一段字节**第一个字节**就与 h2 + * 前言不符(`matched == 0`)时,按先验知识它该走 h1。但如果这一整行连 + * `HTTP/.` 这个版本记号都没有,它同样不可能是任何合法的 h1 请求 + * —— h2spec 3.5/2 的 `INVALID CONNECTION PREFACE\r\n\r\n` 就是这一格。那时把它 + * 交回 h2 会话,让 nghttp2 按前言错误回一个 GOAWAY(PROTOCOL_ERROR),比在 h1 + * 上回一个 400 更接近对端的意图。 + * + * **不是协议嗅探的泛化**:只在"第一个字节已经排除 h2 前言、整行又不是 HTTP/1" + * 这个确定的否定条件上使用;其余情况一律维持原来的先验知识判定。 + * 返回 INCOMPLETE 表示还没看到行尾,调用方可以继续攒。 + */ +h2c_first_line classify_h2c_first_line(const char* data, size_t len) { + size_t nl = std::string::npos; + for (size_t i = 0; i < len; ++i) { + if (data[i] == '\n') { + nl = i; + break; + } + } + if (nl == std::string::npos) return h2c_first_line::INCOMPLETE; + + size_t end = nl; + if (end > 0 && data[end - 1] == '\r') --end; + if (end == 0) return h2c_first_line::NOT_HTTP1; + + // 请求行是 METHOD SP request-target SP HTTP-version。取最后一个空格之后 + // 那一段当版本记号;没有空格或不是 `HTTP/` 开头都算"不是 h1"。 + size_t sp = std::string::npos; + for (size_t i = end; i > 0; --i) { + if (data[i - 1] == ' ') { + sp = i - 1; + break; + } + } + if (sp == std::string::npos) return h2c_first_line::NOT_HTTP1; + const size_t vlen = end - (sp + 1); + if (vlen >= 5 && std::memcmp(data + sp + 1, "HTTP/", 5) == 0) { + return h2c_first_line::HTTP1; + } + return h2c_first_line::NOT_HTTP1; +} #endif /** @@ -956,6 +1004,12 @@ void uvcpp_http_server::set_h3_extended_connect_handler( h3_extended_connect_handler_t handler) { h3_extended_connect_handler_ = std::move(handler); } + +void uvcpp_http_server::set_h3_qpack_encoder_table_policy( + h3_qpack_encoder_table_policy policy, size_t capacity) { + h3_qpack_encoder_table_policy_ = policy; + h3_qpack_encoder_table_capacity_ = capacity; +} #endif std::string uvcpp_http_server::take_upgrade_leftover(uvcpp_tcp_client* client) { @@ -1262,8 +1316,37 @@ void uvcpp_http_server::on_connection_data(uvcpp_tcp_client* client, // // 排在 `raw_data_hook_` **之后**是有意的:那个钩子的契约是"能看见原始字节、 // 也能把连接整个接管走",接管了就不该再有人替它决定协议。 - if (h2c_enabled() && ctx.parser != nullptr && - ctx.h2c == conn_ctx::h2c_probe_state::PROBING && !client->is_tls()) { + if (h2c_enabled() && ctx.parser != nullptr && !client->is_tls() && + (ctx.h2c == conn_ctx::h2c_probe_state::PROBING || + ctx.h2c == conn_ctx::h2c_probe_state::PROBING_LINE)) { + // 第一个字节就与前言不符、第一行还没收全:先攒着,等能判断"它是不是一条 + // 合法 h1 请求行"。这一态只由下面的 `have == 0 && matched == 0` 进入。 + if (ctx.h2c == conn_ctx::h2c_probe_state::PROBING_LINE) { + static const size_t kMaxFirstLine = 8u * 1024u; + ctx.h2c_probe.append(data, len); + const h2c_first_line kind = classify_h2c_first_line( + ctx.h2c_probe.data(), ctx.h2c_probe.size()); + if (kind == h2c_first_line::INCOMPLETE && + ctx.h2c_probe.size() <= kMaxFirstLine) { + return; // 还没看到行尾,继续攒 + } + if (kind == h2c_first_line::NOT_HTTP1) { + // 不是合法 h1 请求行 ⇒ 交回 h2;nghttp2 用 GOAWAY(PROTOCOL_ERROR) + // 把"前言不对"说清楚(h2spec 3.5/2)。 + ctx.h2c = conn_ctx::h2c_probe_state::H2; + std::string pending; + pending.swap(ctx.h2c_probe); + switch_to_h2c(client, pending); // `ctx` 之后悬垂,下面只剩 return + return; + } + // HTTP/1.x,或者第一行长到超过上限:按 h1 收,攒下的原样补喂。 + ctx.h2c = conn_ctx::h2c_probe_state::H1; + std::string pending; + pending.swap(ctx.h2c_probe); + ctx.parser->execute(pending.data(), pending.size()); + return; // 本段已在 pending 里,不能再落到下面的常规路径 + } + const size_t have = ctx.h2c_probe.size(); // `matched` 是**本段里**连着的匹配字节数;`ctx.h2c_probe` 存的是**前面几段** // 攒下的。分开数是为了下面"岔了"那条路能一次喂对:那时攒下的字节要按原样 @@ -1309,6 +1392,27 @@ void uvcpp_http_server::on_connection_data(uvcpp_tcp_client* client, return; } + // 第一个字节就岔开(本段一个字节都没匹配上前言)时,先看这一行到底是不是 + // h1。整行没有 `HTTP/.` ⇒ 两条协议都不成立,交回 h2 让 nghttp2 用 + // GOAWAY(PROTOCOL_ERROR) 收场;行还没收全就先攒到 PROBING_LINE。 + // 注意 `have > 0` 的岔路(本段前面已经攒过前缀)**不走这里**:那正是 + // "P" + "OST ..." 这种一条被切开的正常 h1 请求,必须按原路补喂给 llhttp。 + if (have == 0 && matched == 0) { + const h2c_first_line kind = classify_h2c_first_line(data, len); + if (kind == h2c_first_line::INCOMPLETE) { + ctx.h2c = conn_ctx::h2c_probe_state::PROBING_LINE; + ctx.h2c_probe.assign(data, len); + return; + } + if (kind == h2c_first_line::NOT_HTTP1) { + ctx.h2c = conn_ctx::h2c_probe_state::H2; + std::string pending(data, len); + switch_to_h2c(client, pending); // 同上前提:之后 `ctx` 悬垂 + return; + } + // HTTP/1.x:落到下面定案 h1。 + } + // 岔了 ⇒ 定案 h1,此后这条连接上与 h2c 有关的代码一行都不再跑。攒下的那几段 // 是"看过没吃过"的,按原样补喂给解析器;本段整个落到下面的常规路径上去。 ctx.h2c = conn_ctx::h2c_probe_state::H1; @@ -1484,6 +1588,29 @@ void uvcpp_http_server::on_request_complete(uvcpp_tcp_client* client) { ctx.stream_view_built = false; req.body.clone(ctx.body_buf); + // RFC 9112 §3.2.4: `*` is only valid as the request-target of OPTIONS. + // llhttp parses it as an ordinary URL, so without this branch the router + // answers 404 and leaves the connection open; both are wrong for GET/CONNECT. + if (req.url == "*") { + if (req.method == http_method::HTTP_OPTIONS) { + uvcpp_http_response resp = + uvcpp_http_response::make(http_status::NO_CONTENT, "", 0); + send_response(client, resp); + } else { + reject_early(ctx, client, http_status::BAD_REQUEST, + /*message_will_complete=*/false); + } + return; + } + + // This server is an origin server, not a CONNECT proxy (RFC 9110 §9.3.6). + // A CONNECT request must not be routed as if its authority were a path. + if (req.method == http_method::HTTP_CONNECT) { + reject_early(ctx, client, http_status::METHOD_NOT_ALLOWED, + /*message_will_complete=*/false); + return; + } + // Capture what send_response() needs later: for a deferred response the // parser is reset (and its headers replaced) before the response is sent, // so these cannot be read back off the parser at send time. @@ -3312,6 +3439,10 @@ void uvcpp_http_server::on_quic_connection(uvcpp_quic_connection* conn) { const int li = quic_loop_index_here(); uvcpp_h3_connection* h3 = new uvcpp_h3_connection(conn, /*server_side=*/true); + // 本连接建立时把服务器级策略落下去。setter 在 `start()` 前调用,h3 会话还在 + // 等 `on_alpn` 的 `init()`,此时只记意图,不会改到已发出的 SETTINGS。 + h3->set_qpack_encoder_table_policy(h3_qpack_encoder_table_policy_, + h3_qpack_encoder_table_capacity_); // **先登记、再 start**:`start()` 会同步冲一轮待发字节(三条关键流),那一轮 // 随时可能把对端触发的回调跑起来 —— 那时表里必须已经有这一项,否则一个立刻 // 到达的请求会在一张空表上查不到连接(被静默丢掉)。 diff --git a/src/web/uvcpp_http_server.h b/src/web/uvcpp_http_server.h index 60d8cfde..c614befe 100644 --- a/src/web/uvcpp_http_server.h +++ b/src/web/uvcpp_http_server.h @@ -36,6 +36,13 @@ #include #include +#if UVCPP_HTTP3_ENABLE +// h3 的公开小件(QPACK 策略枚举)必须在 `namespace uvcpp` **外面**引:这个头 +// 自己就开 `namespace uvcpp`,在命名空间里 include 会把它再套一层成 +// `uvcpp::uvcpp`。nghttp3/ngtcp2 的类型仍然不进来(它们在 .cpp 里)。 +#include "http3/uvcpp_h3_common.h" +#endif + namespace uvcpp { #if UVCPP_NGHTTP2_ENABLE @@ -50,7 +57,7 @@ class uvcpp_ssl_context; #if UVCPP_HTTP3_ENABLE // h3 与 QUIC 两层同 h2 那条理由:头都是 pimpl 形状的(nghttp3 / ngtcp2 只在 -// .cpp 里),引了就把"关掉 http3 也能编 web 模块"作废。 +// .cpp 里),这里连它们的头都不引 —— 引了就把"关掉 http3 也能编 web 模块"作废。 class uvcpp_h3_connection; class uvcpp_quic_server; class uvcpp_quic_connection; @@ -481,6 +488,19 @@ class UVCPP_API uvcpp_http_server { using h3_extended_connect_handler_t = std::function; void set_h3_extended_connect_handler(h3_extended_connect_handler_t handler); + + /** + * @brief h3 响应编码端 QPACK 动态表策略(影响此后新建的连接)。 + * + * - `disabled`(默认):容量 0,只用静态表/字面量;官方 H3 验证形态。 + * - `automatic`:保留 nghttp3 默认值(当前 4096)。 + * - `fixed`:使用 `capacity`;0 等同 `disabled`。 + * + * **不是**对端解码表的 `SETTINGS_QPACK_MAX_TABLE_CAPACITY`。已有连接不受 + * 更新影响;需要在 `listen_quic()` 之前或至少在连接建立前设置。 + */ + void set_h3_qpack_encoder_table_policy( + h3_qpack_encoder_table_policy policy, size_t capacity = 0); #endif /** @@ -1144,15 +1164,22 @@ class UVCPP_API uvcpp_http_server { * - @ref H1:比岔了。此后这条连接上与 h2c 有关的代码一行都不再跑。 * - @ref H2:24 字节全中。此刻 `conn_ctx` 会被整个换掉(见 * `switch_to_h2c()`),所以这个态只在不换表那条路上(单测直接观察)有意义。 + * - @ref PROBING_LINE:**第一个字节**就与前言不符,且这一行还没收全。这不是 + * 在两者之间猜:第一个字节已经排除了 h2 前言,此时唯一还能判的是"它是不是 + * 一条合法的 h1 请求行"。整行收全后:有 `HTTP/.` 版本记号 ⇒ @ref H1, + * 没有 ⇒ 交回 h2(nghttp2 会按前言错误回 GOAWAY(PROTOCOL_ERROR),见 + * `classify_h2c_first_line()`)。攒的内容仍在 @ref h2c_probe 里。 * * 只有 `set_h2c_enabled(true)` 且**明文**连接才会离开 @ref PROBING —— 默认 * 配置下这个字段恒为 @ref PROBING 且没人读它。 */ - enum class h2c_probe_state { PROBING, H1, H2 }; + enum class h2c_probe_state { PROBING, PROBING_LINE, H1, H2 }; h2c_probe_state h2c = h2c_probe_state::PROBING; /** - * @brief @ref PROBING 期间攒下的字节,长度 `0..23`。 + * @brief @ref PROBING / @ref PROBING_LINE 期间攒下的字节。 + * + * @ref PROBING 下长度 `0..23`;@ref PROBING_LINE 下是尚未收全的第一行(有上限)。 * * 必须攒:TCP 会把 24 字节前言切成任意几段(`"PRI * HT"` + `"TP/2.0\r\n\r\nSM\r\n\r\n"` * 是合法的到达方式),而"比岔了"的那一刻得把**前面几段**按原样补喂给解析器 @@ -1788,6 +1815,10 @@ class UVCPP_API uvcpp_http_server { #if UVCPP_HTTP3_ENABLE /// h3 extended CONNECT 的接管钩子(#58)。没装时那条流回 501。 h3_extended_connect_handler_t h3_extended_connect_handler_; + /// h3 响应编码端 QPACK 动态表策略;默认 disabled(容量 0)。 + h3_qpack_encoder_table_policy h3_qpack_encoder_table_policy_ = + h3_qpack_encoder_table_policy::disabled; + size_t h3_qpack_encoder_table_capacity_ = 0; #endif std::function close_handler_; /** @brief 新连接钩子(`on_connection`),早于该连接上的任何请求。 */ diff --git a/src/web/uvcpp_ws_connection.cpp b/src/web/uvcpp_ws_connection.cpp index 57b8bb44..b382b93b 100644 --- a/src/web/uvcpp_ws_connection.cpp +++ b/src/web/uvcpp_ws_connection.cpp @@ -208,7 +208,7 @@ void uvcpp_ws_connection::on_tcp_data(uvcpp_buf* buf) { in_read_dispatch_ = true; DispatchGuard guard{this}; - while (n > 0 && !protocol_failed_) { + while (n > 0 && !protocol_failed_ && !close_received_) { size_t used = parser_.execute(p, n); ws_parser_state st = parser_.get_state(); @@ -228,8 +228,20 @@ void uvcpp_ws_connection::on_tcp_data(uvcpp_buf* buf) { } } +namespace { +bool ws_is_valid_close_code(uint16_t code) { + // RFC 6455 §7.4.1: 1004/1005/1006 are reserved and MUST NOT appear on the + // wire; 1015 is reserved for TLS failure. 1012-1014 are not in the base + // protocol table, so reject them too; 3000-4999 are application/private. + if (code >= 3000 && code <= 4999) return true; + if (code < 1000 || code > 1011) return false; + return code != 1004 && code != 1005 && code != 1006; +} +bool ws_is_valid_utf8(const uint8_t* p, size_t n); +} // namespace + void uvcpp_ws_connection::on_ws_frame(const uvcpp_ws_frame& frame) { - if (protocol_failed_) return; + if (protocol_failed_ || close_received_) return; // 逐帧观察(#50):**放在所有自动处理之前**,让调试器看到线上原样 // (含随后会被判协议错误的帧)。回调里可能 send/close,甚至触发协议错误, @@ -272,13 +284,41 @@ void uvcpp_ws_connection::on_ws_frame(const uvcpp_ws_frame& frame) { if (on_pong_) on_pong_(frame.payload.get_const_udata(), frame.payload.size()); break; case ws_opcode::CLOSE: { - auto cd = frame.get_close_code(); - auto cr = frame.get_close_reason(); + // RFC 6455 §5.5.1/§7.4: a close payload of length 1 is malformed; + // a 2-byte code outside the allowed ranges is a protocol error; the + // reason (if present) must be UTF-8. The empty payload is valid and + // means "no status code" — it must not be echoed as 1005. + if (frame.payload.size() == 1) { + protocol_error(ws_close_code::PROTOCOL_ERROR, + "close payload length 1"); + return; + } + ws_close_code cd = frame.get_close_code(); + const std::string cr = frame.get_close_reason(); + if (frame.payload.size() >= 2 && + !ws_is_valid_close_code(static_cast(cd))) { + protocol_error(ws_close_code::PROTOCOL_ERROR, + "invalid close code"); + return; + } + if (frame.payload.size() > 2 && + !ws_is_valid_utf8( + reinterpret_cast(cr.data()), cr.size())) { + protocol_error(ws_close_code::INVALID_PAYLOAD, + "close reason is not valid UTF-8"); + return; + } + // 对端发起了关闭:把帧里的码原样回过去(RFC 6455 §5.5.1),然后把 - // "对端是怎么走的"告诉调用方。**置位要在回调之前** —— 紧随其后的 - // 传输层关闭不该再补一个 1006。 + // “对端是怎么走的”告诉调用方。**置位要在回调之前** —— 紧随其后的 + // 传输层关闭不该再补一个 1006。空 payload 也原样回空帧。 + close_received_ = true; close_notified_ = true; - send_close(cd, cr); + if (frame.payload.size() == 0) { + send_close(ws_close_code::NO_STATUS, std::string()); + } else { + send_close(cd, cr); + } if (on_close_) on_close_(cd, cr); break; } @@ -718,7 +758,10 @@ int uvcpp_ws_connection::send_close(ws_close_code cd, const std::string& rs) { uvcpp_ws_frame f; f.opcode = ws_opcode::CLOSE; // 控制帧负载上限 125 字节(RFC 6455 §5.5);扣掉 2 字节状态码,原因最多 123。 // 超了会拼出一个对端**必须拒绝**的帧,所以在这里截断,而不是让它发出去。 - f.set_close_payload(cd, rs.size() > 123 ? rs.substr(0, 123) : rs); + // 空 close(NO_STATUS)必须保持零负载;1005 是本地占位码,不得上线。 + if (cd != ws_close_code::NO_STATUS) { + f.set_close_payload(cd, rs.size() > 123 ? rs.substr(0, 123) : rs); + } apply_mask(f); return send_frame_impl(f, [this](int) { // 走 client->close():直接关句柄会绕过框架的关闭回调,服务端的客户端对象 diff --git a/src/web/uvcpp_ws_connection.h b/src/web/uvcpp_ws_connection.h index 4e938690..b96c38cf 100644 --- a/src/web/uvcpp_ws_connection.h +++ b/src/web/uvcpp_ws_connection.h @@ -454,6 +454,8 @@ class UVCPP_API uvcpp_ws_connection { uvcpp_buf message_payload_; size_t max_message_size_ = 16u * 1024u * 1024u; bool protocol_failed_ = false; + /// 已经收到对端的 Close:之后的字节一律不再交给解析器(RFC 6455 §5.5.1)。 + bool close_received_ = false; std::string last_parse_error_; #if UVCPP_ZLIB_ENABLE diff --git a/tests/functional/quic_api_func.cpp b/tests/functional/quic_api_func.cpp index 96eafc69..33118c48 100644 --- a/tests/functional/quic_api_func.cpp +++ b/tests/functional/quic_api_func.cpp @@ -542,6 +542,71 @@ void test_close_path(uvcpp_loop& loop, bool idle_timeout_case) { } } +// ========================================================================= +// 5b. QUIC 的 ALPN 是强制协商项 +// ========================================================================= + +/// ALPN 无交集在 QUIC 上必须是 fatal(RFC 9001 §8.1)。 +/// +/// TCP TLS 那条路允许"没协商出 ALPN"继续走(上层回落 h1, +/// `alpn_mismatch::NOACK` 是默认档);QUIC 没有明文模式,也没有可回落的协议 —— +/// 客户端宣告的名单一个都挑不中时,服务端 MUST 回 fatal +/// `no_application_protocol`(RFC 7301 §3.2),握手不能成功。 +/// +/// 判据落在**两个可见结果**上:`connect_cb` 拿到非 0(握手失败),且 `on_alpn` +/// 一次都不响(没有协商出任何协议)。只断言"连接最终关了"不够 —— 空闲超时也 +/// 会把它关掉。 +void test_alpn_mismatch_is_fatal(uvcpp_loop& loop) { + std::cout << " -- QUIC ALPN 无交集必须 fatal" << std::endl; + + uvcpp_ssl_context server_ctx(tls_mode::SERVER, tls_version::TLS_1_3); + if (!server_ctx.generate_self_signed("localhost", 2048)) { + check(false, "生成自签证书失败"); + return; + } + uvcpp_ssl_context client_ctx(tls_mode::CLIENT, tls_version::TLS_1_3); + client_ctx.set_verify_mode(tls_verify_mode::NONE); + + { + uvcpp_quic_server server(&loop); + server.set_ssl_context(&server_ctx); + // 不设 ALPN:走端点默认的 `quic_default_alpn()`("h3")。 + check_eq_i(server.bind("127.0.0.1", 0), 0, "bind(127.0.0.1, 0)"); + check_eq_i(server.listen([](uvcpp_quic_connection*) {}), 0, + "listen() 返回 0"); + const int port = server.configured_port(); + check(port > 0, "listen() 之后 configured_port() 报内核分配的端口"); + + uvcpp_quic_client client(&loop); + client.set_ssl_context(&client_ctx); + client.set_alpn_protos({"bogus"}); + + bool done = false; + int status = 0; + bool alpn_fired = false; + const int rc = client.connect("127.0.0.1", port, [&](int st) { + status = st; + done = true; + }); + check_eq_i(rc, 0, "connect() 返回 0"); + if (rc != 0) return; + + { + uvcpp_quic_connection::callbacks cbs; + cbs.on_alpn = [&](uvcpp_quic_connection&, const std::string&) { + alpn_fired = true; + }; + client.connection()->set_callbacks(cbs); + } + + check(uvcpp_test::wait_until(&loop, [&] { return done; }, + kCloseDeadlineMs), + "无交集握手在 deadline 内收场"); + check(status != 0, "无交集时 connect_cb 拿到非 0(握手失败)"); + check(!alpn_fired, "无交集时 on_alpn 一次都没响"); + } +} + // ========================================================================= // 6. 读侧那三样:FIN 与 RESET 分得开、流额度、STOP_SENDING // ========================================================================= @@ -846,6 +911,7 @@ int main() { check_eq_i(quic_crypto_backend_init(), 0, "为关闭用例重起 crypto 后端"); test_close_path(loop, /*idle_timeout_case=*/true); test_close_path(loop, /*idle_timeout_case=*/false); + test_alpn_mismatch_is_fatal(loop); quic_crypto_backend_free(); // 读侧那三样(FIN/RESET 的分界、流额度、STOP_SENDING)要一条**真握手过的** diff --git a/tests/functional/web_app_h3_http_func.cpp b/tests/functional/web_app_h3_http_func.cpp index 1b29e25a..36a14b19 100644 --- a/tests/functional/web_app_h3_http_func.cpp +++ b/tests/functional/web_app_h3_http_func.cpp @@ -213,11 +213,186 @@ void test_h3_http() { t.shutdown(); } +/// 对端把 QPACK 解码器流"开了就关":类型码 `0x03` 与 FIN 挤在同一次读里。 +/// +/// nghttp3 1.18 的 `conn_read_uni()` 认完类型码就直接返回,**不看 fin** —— +/// 若这一层也把"FIN 已交"记成既成事实,关键流被关这件事永远到不了 nghttp3, +/// QPACK 4.2 / HTTP/3 6.2.1 要求的 H3_CLOSED_CRITICAL_STREAM 就被吞掉。 +/// 判据在线上:服务端必须以 0x0104 收尾整条连接。 +void test_h3_critical_stream_close() { + TestApp t; + t.build(); + const int qport = t.start(); + check(qport > 0, "critical-stream 用例的 QUIC 端点起来(端口 " + + std::to_string(qport) + ")"); + if (qport <= 0) { + t.shutdown(); + return; + } + + uvcpp_loop loop; + uvcpp_ssl_context client_ctx(tls_mode::CLIENT, tls_version::TLS_1_3); + client_ctx.set_verify_mode(tls_verify_mode::NONE); + + uvcpp_quic_client client(&loop); + client.set_ssl_context(&client_ctx); + + bool connected = false; + int connect_status = 12345; + check(client.connect("127.0.0.1", qport, [&](int st) { + connected = true; + connect_status = st; + }) == 0, + "critical-stream 用例 connect 受理"); + check(uvcpp_test::wait_until(&loop, [&] { return connected; }, kDeadlineMs), + "critical-stream 用例握手完成"); + if (!connected || connect_status != 0) { + t.shutdown(); + return; + } + + uvcpp_quic_connection* qc = client.connection(); + check(qc != nullptr, "握手后 connection() 非空"); + if (qc == nullptr) { + t.shutdown(); + return; + } + + bool closed = false; + int close_code = 0; + uvcpp_quic_connection::callbacks cbs; + cbs.on_close = [&](uvcpp_quic_connection&, int code) { + closed = true; + close_code = code; + }; + qc->set_callbacks(cbs); + + const int64_t sid = qc->open_stream(false); + check(sid >= 0, "开一条单向流(流号 " + std::to_string(sid) + ")"); + if (sid >= 0) { + const char decoder_stream_type = 0x03; // RFC 9204 §4.2 + check(qc->write_stream(sid, &decoder_stream_type, 1, true) == 0, + "写 0x03 + FIN(类型码与 FIN 同一段)"); + check(uvcpp_test::wait_until(&loop, [&] { return closed; }, kDeadlineMs), + "服务端关闭了连接(没把关键流关闭当无事发生)"); + check(close_code == 0x0104, + "关闭码是 H3_CLOSED_CRITICAL_STREAM(实际 " + + std::to_string(close_code) + ")"); + } + + t.shutdown(); +} + +/// 客户端控制流里的五类违规。每一类都要求服务端以 RFC 9114 规定的错误码 +/// 收尾整条连接;nghttp3 1.18 原本在这五处要么不报错、要么回错码。 +/// +/// 载荷都带控制流类型码 `0x00`,后面跟一个空的 SETTINGS 帧(需要时先满足 +/// "首个控制帧必须是 SETTINGS"),再跟违规帧。 +void test_h3_control_stream_errors() { + TestApp t; + t.build(); + const int qport = t.start(); + check(qport > 0, "control-stream 用例的 QUIC 端点起来(端口 " + + std::to_string(qport) + ")"); + if (qport <= 0) { + t.shutdown(); + return; + } + + struct Case { + const char* name; + const char* bytes; + size_t len; + int expected; + }; + + // 0x00 = 控制流;0x04 0x00 = 空 SETTINGS。 + // 同一个 SETTINGS 标识 0x40 出现两次(第二对是 0x40 / 0x00)。 + static const char kDupSettings[] = "\x00\x04\x06\x40\x40\x00\x40\x40\x00"; + // CANCEL_PUSH push ID 0:服务端没发过 MAX_PUSH_ID,任何 push ID 都不允许。 + static const char kCancelPush[] = "\x00\x04\x00\x03\x01\x00"; + // MAX_PUSH_ID 5 之后收到 3。 + static const char kMaxPushDown[] = + "\x00\x04\x00\x0d\x01\x05\x0d\x01\x03"; + // MAX_PUSH_ID 5 后面多一个字节。 + static const char kMaxPushTrailing[] = "\x00\x04\x00\x0d\x02\x05\x00"; + // GOAWAY 帧声明 1 GiB 长度(8 字节 varint:0xc0 ... ),只发帧头。 + static const char kOverLong[] = + "\x00\x04\x00\x07\xc0\x00\x00\x00\x40\x00\x00\x00"; + + const Case cases[] = { + {"重复 SETTINGS 标识", kDupSettings, sizeof(kDupSettings) - 1, 0x0109}, + {"CANCEL_PUSH 的 push ID 未获允许", kCancelPush, + sizeof(kCancelPush) - 1, 0x0108}, + {"MAX_PUSH_ID 下降", kMaxPushDown, sizeof(kMaxPushDown) - 1, 0x0108}, + {"MAX_PUSH_ID 尾部多一个字节", kMaxPushTrailing, + sizeof(kMaxPushTrailing) - 1, 0x0106}, + {"控制流超长帧(声明 1 GiB)", kOverLong, sizeof(kOverLong) - 1, 0x0107}, + }; + + for (size_t i = 0; i < sizeof(cases) / sizeof(cases[0]); ++i) { + const Case& c = cases[i]; + const std::string what(c.name); + + uvcpp_loop loop; + uvcpp_ssl_context client_ctx(tls_mode::CLIENT, tls_version::TLS_1_3); + client_ctx.set_verify_mode(tls_verify_mode::NONE); + + uvcpp_quic_client client(&loop); + client.set_ssl_context(&client_ctx); + + bool connected = false; + int connect_status = 12345; + check(client.connect("127.0.0.1", qport, [&](int st) { + connected = true; + connect_status = st; + }) == 0, + what + ":connect 受理"); + check(uvcpp_test::wait_until(&loop, [&] { return connected; }, kDeadlineMs), + what + ":握手完成"); + if (!connected || connect_status != 0) { + continue; + } + + uvcpp_quic_connection* qc = client.connection(); + check(qc != nullptr, what + ":connection() 非空"); + if (qc == nullptr) { + continue; + } + + bool closed = false; + int close_code = 0; + uvcpp_quic_connection::callbacks cbs; + cbs.on_close = [&](uvcpp_quic_connection&, int code) { + closed = true; + close_code = code; + }; + qc->set_callbacks(cbs); + + const int64_t sid = qc->open_stream(false); + check(sid >= 0, what + ":开一条单向控制流"); + if (sid < 0) { + continue; + } + check(qc->write_stream(sid, c.bytes, c.len, false) == 0, + what + ":写出违规控制帧"); + check(uvcpp_test::wait_until(&loop, [&] { return closed; }, kDeadlineMs), + what + ":服务端关闭了连接"); + check(close_code == c.expected, + what + ":关闭码 " + std::to_string(c.expected) + "(实际 " + + std::to_string(close_code) + ")"); + } + + t.shutdown(); +} + } // namespace int main() { std::cout << "web_app over HTTP/3 (#58)" << std::endl; test_h3_http(); + test_h3_critical_stream_close(); + test_h3_control_stream_errors(); if (g_fail != 0) { std::cerr << g_fail << " check(s) failed" << std::endl; return 1; diff --git a/tests/functional/web_h2_cleartext_func.cpp b/tests/functional/web_h2_cleartext_func.cpp index c577cc54..a15350b5 100644 --- a/tests/functional/web_h2_cleartext_func.cpp +++ b/tests/functional/web_h2_cleartext_func.cpp @@ -231,6 +231,50 @@ bool has_frame_type(const std::string& s, unsigned type) { return false; } +/// 找帧类型 @p type 且 ACK 标志置位的帧,载荷与 @p data 相同。 +bool has_ack_frame(const std::string& s, unsigned type, const std::string& data) { + size_t off = 0; + while (off + 9 <= s.size()) { + const unsigned char* p = + reinterpret_cast(s.data()) + off; + const uint32_t len = (static_cast(p[0]) << 16) | + (static_cast(p[1]) << 8) | + static_cast(p[2]); + if (off + 9 + len > s.size()) break; + if (p[3] == type && (p[4] & 0x01u) != 0 && len == data.size() && + std::memcmp(p + 9, data.data(), data.size()) == 0) { + return true; + } + off += 9 + len; + } + return false; +} + +/// 找 GOAWAY 帧并返回它的错误码;没有完整的 GOAWAY 返回 -1。 +/// +/// GOAWAY 的载荷是 4 字节 last-stream-id + 4 字节错误码;错误码在载荷的第 +/// 5..8 个字节(也就是 `p + 9 + 4` 起)。只看完整帧:截断的尾巴不算。 +int goaway_error_code(const std::string& s) { + size_t off = 0; + while (off + 9 <= s.size()) { + const unsigned char* p = + reinterpret_cast(s.data()) + off; + const uint32_t len = (static_cast(p[0]) << 16) | + (static_cast(p[1]) << 8) | + static_cast(p[2]); + if (off + 9 + len > s.size()) break; + if (p[3] == 0x7u && len >= 8) { + const unsigned char* q = p + 9; + return static_cast((static_cast(q[4]) << 24) | + (static_cast(q[5]) << 16) | + (static_cast(q[6]) << 8) | + static_cast(q[7])); + } + off += 9 + len; + } + return -1; +} + uvcpp_http_request make_req(http_method m, const std::string& url, const std::string& host = "example.com") { uvcpp_http_request r; @@ -1117,6 +1161,120 @@ void test_client_session_scheme_follows_transport() { srv.shutdown(); } +// ========================================================================= +// 第 11 轮:第一个字节就排除 h2 前言时的分类 +// ========================================================================= + +/** + * @brief 非法 h2 前言必须按 h2 的连接错误收场;拆开的第一行仍是 h1。 + * + * 两个方向用的是**同一个**分类判据,所以放在一轮里: + * - `INVALID CONNECTION PREFACE\r\n\r\n` 没有 `HTTP/.` 版本记号, + * 两条协议都不成立。按 h1 回 400 会让 h2spec 3.5/2 拿到一段 HTTP/1 报文 + * 后 `unexpected EOF`;正确做法是把它交回 h2,让 nghttp2 按前言错误 + * GOAWAY(PROTOCOL_ERROR)(`last_error() == -903` 那条路)。 + * - 同一判据下,第一行只是**还没收全**时不能提前定案:`"GE"` 既不是完整的 + * h1 请求行、也排除了 h2 前言(首字节不是 `P`)。这时攒到 `PROBING_LINE`, + * 整行收全看到 `HTTP/1.1` 再按 h1 补喂,一个字节都不许丢。 + */ +void test_invalid_preface_and_split_first_line() { + std::cout << "[11] 非法 h2 前言 → GOAWAY(PROTOCOL_ERROR);拆开的首行仍走 h1" + << std::endl; + TestServer srv; + const int port = srv.start(/*h2c=*/true); + if (port <= 0) { + check(false, "服务端起来了"); + return; + } + + { + std::string got; + const bool ok = write_then_read( + port, {std::string("INVALID CONNECTION PREFACE\r\n\r\n")}, 0, got, + [](const std::string& s) { return goaway_error_code(s) == 1; }, 3000); + info("非法前言的回复 " + std::to_string(got.size()) + " 字节:" + + frame_dump(got)); + check(ok, "收到了 GOAWAY(PROTOCOL_ERROR)"); + check(got.find("HTTP/1.1") == std::string::npos, + "没有回落成 HTTP/1 400(h2spec 3.5/2 的 unexpected EOF 根因)"); + } + + { + std::string got; + const bool ok = write_then_read( + port, + {std::string("GE"), + std::string("T /hello HTTP/1.1\r\nHost: h\r\nConnection: close\r\n\r\n")}, + /*gap_ms=*/80, got, + [](const std::string& s) { + return looks_like_h1(s) && s.find("200") != std::string::npos; + }, + 3000); + info("拆开首行的回复首行 " + + got.substr(0, got.find("\r\n") == std::string::npos + ? got.size() + : got.find("\r\n"))); + check(srv.chunk_count() >= 2, "前提:首行确实跨了多个读段"); + check(ok, "首行拆成 \"GE\" + \"T ... HTTP/1.1\" 仍按 h1 派发(没有吞字节)"); + } + + srv.shutdown(); +} + +// ========================================================================= +// 第 12 轮:对端 GOAWAY 之后的 PING 必须由原始层 ACK +// ========================================================================= + +/** + * @brief 收到对端 GOAWAY 后立刻 close 会把紧随的 PING 变成 TCP RST。 + * + * `nghttp2` 在没有活跃流时会把 `want_read()` 置 0 并压掉 PING ACK,而 + * h2spec generic/3.8/1 与 http2/7/1 的验收是“PING ACK **或** 连接关闭”。 + * 曾经的做法是收到 GOAWAY 就关连接:PING 晚一步到达就撞上已关闭的 fd, + * 对端读到 `connection reset by peer`(同一棵树三次跑会两次失败、一次通过)。 + * + * 现在的契约:GOAWAY 之后留在读状态,`sniff_raw_frames()` 见到 PING 直接回 + * 原始 ACK;对端收到 ACK 后自己关,读回调的 EOF 再走断开通知。本轮的判据 + * 是**收到与 opaque data 一致的 PING ACK**,而不是“连接被关掉”。 + */ +void test_peer_goaway_ping_acked() { + std::cout << "[12] 对端 GOAWAY 之后的 PING 由原始层 ACK(不是立刻关连接)" + << std::endl; + TestServer srv; + const int port = srv.start(/*h2c=*/true); + if (port <= 0) { + check(false, "服务端起来了"); + return; + } + + // 前言 + 空 SETTINGS:完成握手,但不开任何流(GOAWAY 后 nghttp2 正是 + // “没有活跃流 ⇒ want_read 归零”的那一格)。 + std::string hello(kPreface, kPrefaceLen); + hello.append("\x00\x00\x00\x04\x00\x00\x00\x00\x00", 9); + + std::string goaway; + goaway.append("\x00\x00\x08\x07\x00\x00\x00\x00\x00", 9); + goaway.append("\x00\x00\x00\x00\x00\x00\x00\x00", 8); + + const std::string ping_data("h2spec\0\0", 8); + std::string ping; + ping.append("\x00\x00\x08\x06\x00\x00\x00\x00\x00", 9); + ping.append(ping_data); + + std::string got; + const bool ok = write_then_read( + port, {hello, goaway, ping}, /*gap_ms=*/40, got, + [&ping_data](const std::string& s) { + return has_ack_frame(s, 0x6u, ping_data); + }, + 3000); + info("GOAWAY+PING 的回复 " + std::to_string(got.size()) + " 字节:" + + frame_dump(got)); + check(ok, "收到了与 PING 载荷一致的 ACK 帧(没有 RST、也没有静默超时)"); + + srv.shutdown(); +} + } // namespace int main() { @@ -1134,6 +1292,8 @@ int main() { test_h2c_disabled_control(); test_scheme_must_match_cleartext(); test_client_session_scheme_follows_transport(); + test_invalid_preface_and_split_first_line(); + test_peer_goaway_ping_acked(); std::cout << "[functional web_h2_cleartext] done failures=" << g_failures << std::endl; diff --git a/tests/functional/web_http_parser_func.cpp b/tests/functional/web_http_parser_func.cpp index 7def37e5..be925aca 100644 --- a/tests/functional/web_http_parser_func.cpp +++ b/tests/functional/web_http_parser_func.cpp @@ -85,6 +85,24 @@ static bool test_header_ops() { return true; } +static bool test_obs_fold_rejected() { + // llhttp happily treats a folded continuation as a second value callback; + // RFC 9112 §5.1 requires the server to reject it. Split the request at the + // fold so the check also covers the two-read boundary. + uvcpp_http_parser parser(http_parser_mode::PARSE_REQUEST); + const char* head = "GET / HTTP/1.1\r\nHost: x\r\nX-Test: a\r\n"; + const char* tail = " b\r\n\r\n"; + parser.execute(head, strlen(head)); + parser.execute(tail, strlen(tail)); + if (!parser.has_error()) return false; + // A normal value with two spaces after the colon is not a fold. + uvcpp_http_parser normal(http_parser_mode::PARSE_REQUEST); + const char* ok = "GET / HTTP/1.1\r\nHost: x\r\nX-Test: b\r\n\r\n"; + normal.execute(ok, strlen(ok)); + normal.finish(); + return !normal.has_error() && normal.is_complete(); +} + static bool test_parser_reset() { uvcpp_http_parser parser(http_parser_mode::PARSE_REQUEST); const char* req1 = "GET /first HTTP/1.1\r\n\r\n"; @@ -151,6 +169,7 @@ int main() { {"response_to_string", test_response_to_string}, {"version_enum", test_version_enum}, {"header_ops", test_header_ops}, + {"obs_fold_rejected", test_obs_fold_rejected}, {"parser_reset", test_parser_reset}, {"request_move_semantics", test_request_move_semantics}, }; diff --git a/tests/tools/doc_line_refs.lock b/tests/tools/doc_line_refs.lock index d913840d..8cf14595 100644 --- a/tests/tools/doc_line_refs.lock +++ b/tests/tools/doc_line_refs.lock @@ -8,57 +8,63 @@ CMakeLists.txt:1135-1135 075f8ca073d6e384 075f8ca073d6e384 - CMakeLists.txt:1142-1142 f209c420bc688e6b f209c420bc688e6b - CMakeLists.txt:152-152 147faa0531ba28f7 147faa0531ba28f7 - CMakeLists.txt:1600-1600 bca1eb88b6c022d6 bca1eb88b6c022d6 - -CMakeLists.txt:1677-1677 ae83b5db663cfc83 ae83b5db663cfc83 - CMakeLists.txt:173-173 c60affd86ed9f92a c60affd86ed9f92a - -CMakeLists.txt:1739-1739 4c32db63ce9707d7 4c32db63ce9707d7 - -CMakeLists.txt:1790-1790 c9a89b64a410bd35 c9a89b64a410bd35 - -CMakeLists.txt:1804-1804 1aa4a028404af983 1aa4a028404af983 - +CMakeLists.txt:1739-1739 b77147acb5f6e882 b77147acb5f6e882 - +CMakeLists.txt:1809-1809 ae83b5db663cfc83 ae83b5db663cfc83 - +CMakeLists.txt:1871-1871 4c32db63ce9707d7 4c32db63ce9707d7 - CMakeLists.txt:189-189 ec21dd9177da1017 ec21dd9177da1017 - -CMakeLists.txt:1893-1901 69e14c6236c163b2 d6de6970f4db1a07 b9d79421b34560fa -CMakeLists.txt:1909-1915 c5fc893aa7d18fa3 d483a8300239fe81 84596bbfaa11fe0a -CMakeLists.txt:2074-2074 81476067003985a5 81476067003985a5 - -CMakeLists.txt:2134-2134 81476067003985a5 81476067003985a5 - +CMakeLists.txt:1893-1901 ac51d3277ae7759b 0b4e17e47efd5fc7 1ef67e645ca679f1 +CMakeLists.txt:1922-1922 c9a89b64a410bd35 c9a89b64a410bd35 - +CMakeLists.txt:1936-1936 1aa4a028404af983 1aa4a028404af983 - +CMakeLists.txt:2041-2047 c5fc893aa7d18fa3 d483a8300239fe81 84596bbfaa11fe0a +CMakeLists.txt:2074-2074 564aa47eea78515b 564aa47eea78515b - +CMakeLists.txt:2134-2134 35c5bbd55a4d3460 35c5bbd55a4d3460 - CMakeLists.txt:219-219 2c0786b391ddc1c8 2c0786b391ddc1c8 - -CMakeLists.txt:2226-2226 efedb37c4c19a3c0 efedb37c4c19a3c0 - -CMakeLists.txt:2334-2343 7e0525f67ce2a0c8 d483a8300239fe81 7e66cb3bad5c4ce1 -CMakeLists.txt:2342-2342 7e66cb3bad5c4ce1 7e66cb3bad5c4ce1 - -CMakeLists.txt:2400-2400 e6eaf14767522ccb e6eaf14767522ccb - -CMakeLists.txt:2400-2402 3b4c91b678196c72 2edef8311cc16c7d 4203c17caf76ca71 -CMakeLists.txt:2408-2409 1295d64247ee5ebf f6eb70bb68e31c3d bc0f1401494fb527 -CMakeLists.txt:2444-2444 dd1f1235f833821d dd1f1235f833821d - -CMakeLists.txt:2449-2449 110771a2981514e9 110771a2981514e9 - -CMakeLists.txt:2458-2458 519a4cb6beee59f4 519a4cb6beee59f4 - -CMakeLists.txt:2472-2472 3639f058cd92a2cd 3639f058cd92a2cd - +CMakeLists.txt:2206-2206 81476067003985a5 81476067003985a5 - +CMakeLists.txt:2266-2266 81476067003985a5 81476067003985a5 - +CMakeLists.txt:2342-2342 765acf2a1152c437 765acf2a1152c437 - +CMakeLists.txt:2358-2358 efedb37c4c19a3c0 efedb37c4c19a3c0 - +CMakeLists.txt:2400-2402 6a18d676063a9d73 03d4d8da722cbadd dbcd501efd5781b3 +CMakeLists.txt:2466-2475 7e0525f67ce2a0c8 d483a8300239fe81 7e66cb3bad5c4ce1 CMakeLists.txt:25-25 835af525b88bec74 835af525b88bec74 - -CMakeLists.txt:2636-2636 ba10ebbf2070090e ba10ebbf2070090e - -CMakeLists.txt:2823-2824 9d5a10e41ac88322 d516e58d8db25913 ae23b666e16ecffe -CMakeLists.txt:2850-2850 a14321593b17fdba a14321593b17fdba - -CMakeLists.txt:2852-2852 3a31fde62e9b04b5 3a31fde62e9b04b5 - +CMakeLists.txt:2532-2532 e6eaf14767522ccb e6eaf14767522ccb - +CMakeLists.txt:2532-2534 3b4c91b678196c72 2edef8311cc16c7d 4203c17caf76ca71 +CMakeLists.txt:2540-2541 1295d64247ee5ebf f6eb70bb68e31c3d bc0f1401494fb527 +CMakeLists.txt:2576-2576 dd1f1235f833821d dd1f1235f833821d - +CMakeLists.txt:2581-2581 110771a2981514e9 110771a2981514e9 - +CMakeLists.txt:2590-2590 519a4cb6beee59f4 519a4cb6beee59f4 - +CMakeLists.txt:2604-2604 3639f058cd92a2cd 3639f058cd92a2cd - +CMakeLists.txt:2768-2768 ba10ebbf2070090e ba10ebbf2070090e - +CMakeLists.txt:2823-2824 733b2bbc6049e959 d08f88df745fa795 78018c5c6f7c9e97 +CMakeLists.txt:2982-2982 a14321593b17fdba a14321593b17fdba - +CMakeLists.txt:2984-2984 3a31fde62e9b04b5 3a31fde62e9b04b5 - CMakeLists.txt:302-316 59b22ad7fdc516ee 89e15674e4730156 c5cb01bc0af84c23 CMakeLists.txt:303-303 695784a24021eabf 695784a24021eabf - -CMakeLists.txt:3031-3073 a9e96e5f6c968f9c d483a8300239fe81 a0b5d54b55c00ee6 CMakeLists.txt:313-314 f98b9cc25b0f3082 9bdbf2dd785f40c4 7e30539740cb0a1b CMakeLists.txt:316-316 89e15674e4730156 89e15674e4730156 - +CMakeLists.txt:3163-3205 a9e96e5f6c968f9c d483a8300239fe81 a0b5d54b55c00ee6 CMakeLists.txt:32-34 8268b2f87aeffcb3 45a477e305de30bc a2610ceafefb36ae -CMakeLists.txt:3215-3215 f1e99550dd80dc7d f1e99550dd80dc7d - -CMakeLists.txt:3335-3335 9b420934030132df 9b420934030132df - -CMakeLists.txt:3379-3379 9e1f3efdb9da2727 9e1f3efdb9da2727 - -CMakeLists.txt:3389-3877 15cfbeb60b162cc0 13984a2b1a4c9256 a6513f3f3ec4ca4c -CMakeLists.txt:3422-3422 017f72fdf67f5f9c 017f72fdf67f5f9c - -CMakeLists.txt:3436-3436 ba7837489a6f698d ba7837489a6f698d - +CMakeLists.txt:3347-3347 f1e99550dd80dc7d f1e99550dd80dc7d - +CMakeLists.txt:3422-3422 dc252a98e4167541 dc252a98e4167541 - +CMakeLists.txt:3436-3436 ceb728b53e68ea31 ceb728b53e68ea31 - +CMakeLists.txt:3467-3467 9b420934030132df 9b420934030132df - CMakeLists.txt:35-35 622cef3e23980a0b 622cef3e23980a0b - -CMakeLists.txt:3624-3627 9ee2634d8590c8a8 d483a8300239fe81 eedf8624b192179d -CMakeLists.txt:3648-3653 136099b61c02b874 2da86ae33be9196d 439ae4e87a125249 +CMakeLists.txt:3511-3511 9e1f3efdb9da2727 9e1f3efdb9da2727 - +CMakeLists.txt:3521-4009 15cfbeb60b162cc0 13984a2b1a4c9256 a6513f3f3ec4ca4c +CMakeLists.txt:3648-3653 4548d51a2211b004 f065814c46c1a16d c7bbf55004d40e30 CMakeLists.txt:371-371 5897d2538d488fb9 5897d2538d488fb9 - -CMakeLists.txt:3728-3729 0783bddb14762bbf 77ae7433df62df69 7b7da528bdd6b3dc CMakeLists.txt:373-373 ee4796ba98a0da0b ee4796ba98a0da0b - -CMakeLists.txt:3738-3738 dc47a271c1e60add dc47a271c1e60add - -CMakeLists.txt:3756-3756 03e1cd70f2221b46 03e1cd70f2221b46 - -CMakeLists.txt:3758-3758 67e118285cc2d304 67e118285cc2d304 - -CMakeLists.txt:3779-3779 23328eefdf8e4fee 23328eefdf8e4fee - -CMakeLists.txt:3891-3894 809b3c536e6c4740 d483a8300239fe81 2da83c91fe5c72e5 -CMakeLists.txt:3985-3985 714c97211cb46a65 714c97211cb46a65 - -CMakeLists.txt:4093-4093 cd4e49682028492d cd4e49682028492d - +CMakeLists.txt:3756-3759 9ee2634d8590c8a8 d483a8300239fe81 eedf8624b192179d +CMakeLists.txt:3758-3758 eedf8624b192179d eedf8624b192179d - +CMakeLists.txt:3780-3785 136099b61c02b874 2da86ae33be9196d 439ae4e87a125249 +CMakeLists.txt:3860-3861 0783bddb14762bbf 77ae7433df62df69 7b7da528bdd6b3dc +CMakeLists.txt:3870-3870 dc47a271c1e60add dc47a271c1e60add - +CMakeLists.txt:3888-3888 03e1cd70f2221b46 03e1cd70f2221b46 - +CMakeLists.txt:3891-3894 22b1f2aa3721fa21 ab1a455968150ba0 697982e3b1486f68 +CMakeLists.txt:3911-3911 23328eefdf8e4fee 23328eefdf8e4fee - +CMakeLists.txt:4023-4026 809b3c536e6c4740 d483a8300239fe81 2da83c91fe5c72e5 +CMakeLists.txt:4117-4117 714c97211cb46a65 714c97211cb46a65 - +CMakeLists.txt:4225-4225 cd4e49682028492d cd4e49682028492d - CMakeLists.txt:49-56 0805a0e3033f88a3 1bc5922231c799b4 a0b5d54b55c00ee6 CMakeLists.txt:563-563 285b3125d1799b48 285b3125d1799b48 - CMakeLists.txt:574-574 aa41a613c3dea36a aa41a613c3dea36a - @@ -200,38 +206,39 @@ src/http2/uvcpp_h2_common.h:44-44 3a585113c0d5df67 3a585113c0d5df67 - src/http2/uvcpp_h2_common.h:55-55 8c65900c6c823ac1 8c65900c6c823ac1 - src/http2/uvcpp_h2_common.h:57-57 97d70360df9ddcc8 97d70360df9ddcc8 - src/http2/uvcpp_h2_common.h:79-79 1c1798eb1d79e423 1c1798eb1d79e423 - -src/http2/uvcpp_h2_connection.cpp:115-115 5c485414780002dc 5c485414780002dc - -src/http2/uvcpp_h2_connection.cpp:157-168 e92e5fa6cca68614 a320758ec45364e5 778ce86d4e1997dc -src/http2/uvcpp_h2_connection.cpp:308-308 03f012ead975d4f8 03f012ead975d4f8 - -src/http2/uvcpp_h2_connection.cpp:493-493 45156c0d70e631d2 45156c0d70e631d2 - +src/http2/uvcpp_h2_connection.cpp:124-124 5c485414780002dc 5c485414780002dc - +src/http2/uvcpp_h2_connection.cpp:328-344 af0ead3cc22d3244 a320758ec45364e5 778ce86d4e1997dc +src/http2/uvcpp_h2_connection.cpp:497-497 03f012ead975d4f8 03f012ead975d4f8 - src/http2/uvcpp_h2_connection.cpp:56-56 f8438f07c67149dc f8438f07c67149dc - -src/http2/uvcpp_h2_connection.cpp:96-96 272ecb7661217018 272ecb7661217018 - -src/http2/uvcpp_h2_connection.h:100-100 b12921bddf0f0c9f b12921bddf0f0c9f - -src/http2/uvcpp_h2_connection.h:104-104 b98fb419567a4d6b b98fb419567a4d6b - -src/http2/uvcpp_h2_connection.h:109-109 ba563d2f5113b9a9 ba563d2f5113b9a9 - -src/http2/uvcpp_h2_connection.h:127-127 1916a9d1224fd49e 1916a9d1224fd49e - -src/http2/uvcpp_h2_connection.h:153-156 88b4d0fd05f25d40 6e84577f4eca9c1c ec379aaf15588542 -src/http2/uvcpp_h2_connection.h:158-158 b4f139709b297255 b4f139709b297255 - -src/http2/uvcpp_h2_connection.h:158-162 2edc8d113a3bad32 11c68d86df8db9eb 590400e03a50c270 -src/http2/uvcpp_h2_connection.h:171-171 09d78433e2a134da 09d78433e2a134da - -src/http2/uvcpp_h2_connection.h:174-174 8e316629a3defbc3 8e316629a3defbc3 - -src/http2/uvcpp_h2_connection.h:177-177 abd17862eef98ff0 abd17862eef98ff0 - -src/http2/uvcpp_h2_connection.h:179-191 df26cdaf2451de4d 0a89ed93c999839c 8f07fe0c931c8d1e -src/http2/uvcpp_h2_connection.h:230-230 d09f4b4b176afd28 d09f4b4b176afd28 - -src/http2/uvcpp_h2_connection.h:27-27 24a0ea5ff3bfa408 24a0ea5ff3bfa408 - -src/http2/uvcpp_h2_connection.h:34-34 3e409f60925aba65 3e409f60925aba65 - -src/http2/uvcpp_h2_connection.h:46-46 fe2f6bada61f4694 fe2f6bada61f4694 - -src/http2/uvcpp_h2_connection.h:46-51 8f9994fa062022f0 c3180af503927f63 562c5b89e162f7fc -src/http2/uvcpp_h2_connection.h:54-54 d09f4b4b176afd28 d09f4b4b176afd28 - -src/http2/uvcpp_h2_connection.h:58-58 ae8b03418f41a26f ae8b03418f41a26f - -src/http2/uvcpp_h2_connection.h:70-70 d6e15e85dd93eaf0 d6e15e85dd93eaf0 - -src/http2/uvcpp_h2_connection.h:74-74 ba98e21b46a7f3c3 ba98e21b46a7f3c3 - -src/http2/uvcpp_h2_session.cpp:1004-1004 8de87eb8d77bc8ec 8de87eb8d77bc8ec - -src/http2/uvcpp_h2_session.cpp:1017-1017 8a9f9b8835829f00 8a9f9b8835829f00 - -src/http2/uvcpp_h2_session.cpp:1244-1250 cd15d5a39dc61848 9ec3f4c602e73a0a 48d033810df113d5 -src/http2/uvcpp_h2_session.cpp:1250-1250 9ec3f4c602e73a0a 9ec3f4c602e73a0a - -src/http2/uvcpp_h2_session.cpp:1360-1360 b1e5239df8d0f29d b1e5239df8d0f29d - -src/http2/uvcpp_h2_session.cpp:1733-1733 fec5526e48281d9a fec5526e48281d9a - +src/http2/uvcpp_h2_connection.cpp:692-692 45156c0d70e631d2 45156c0d70e631d2 - +src/http2/uvcpp_h2_connection.cpp:98-98 272ecb7661217018 272ecb7661217018 - +src/http2/uvcpp_h2_connection.h:102-102 b12921bddf0f0c9f b12921bddf0f0c9f - +src/http2/uvcpp_h2_connection.h:106-106 b98fb419567a4d6b b98fb419567a4d6b - +src/http2/uvcpp_h2_connection.h:111-111 ba563d2f5113b9a9 ba563d2f5113b9a9 - +src/http2/uvcpp_h2_connection.h:129-129 1916a9d1224fd49e 1916a9d1224fd49e - +src/http2/uvcpp_h2_connection.h:155-158 88b4d0fd05f25d40 6e84577f4eca9c1c ec379aaf15588542 +src/http2/uvcpp_h2_connection.h:160-160 b4f139709b297255 b4f139709b297255 - +src/http2/uvcpp_h2_connection.h:160-164 2edc8d113a3bad32 11c68d86df8db9eb 590400e03a50c270 +src/http2/uvcpp_h2_connection.h:173-173 09d78433e2a134da 09d78433e2a134da - +src/http2/uvcpp_h2_connection.h:176-176 8e316629a3defbc3 8e316629a3defbc3 - +src/http2/uvcpp_h2_connection.h:179-179 abd17862eef98ff0 abd17862eef98ff0 - +src/http2/uvcpp_h2_connection.h:181-193 df26cdaf2451de4d 0a89ed93c999839c 8f07fe0c931c8d1e +src/http2/uvcpp_h2_connection.h:245-245 d09f4b4b176afd28 d09f4b4b176afd28 - +src/http2/uvcpp_h2_connection.h:29-29 24a0ea5ff3bfa408 24a0ea5ff3bfa408 - +src/http2/uvcpp_h2_connection.h:36-36 3e409f60925aba65 3e409f60925aba65 - +src/http2/uvcpp_h2_connection.h:48-48 fe2f6bada61f4694 fe2f6bada61f4694 - +src/http2/uvcpp_h2_connection.h:48-53 8f9994fa062022f0 c3180af503927f63 562c5b89e162f7fc +src/http2/uvcpp_h2_connection.h:56-56 d09f4b4b176afd28 d09f4b4b176afd28 - +src/http2/uvcpp_h2_connection.h:60-60 ae8b03418f41a26f ae8b03418f41a26f - +src/http2/uvcpp_h2_connection.h:72-72 d6e15e85dd93eaf0 d6e15e85dd93eaf0 - +src/http2/uvcpp_h2_connection.h:76-76 ba98e21b46a7f3c3 ba98e21b46a7f3c3 - +src/http2/uvcpp_h2_session.cpp:1000-1000 ffe6316c076fe7ee ffe6316c076fe7ee - +src/http2/uvcpp_h2_session.cpp:1010-1010 8de87eb8d77bc8ec 8de87eb8d77bc8ec - +src/http2/uvcpp_h2_session.cpp:1023-1023 8a9f9b8835829f00 8a9f9b8835829f00 - +src/http2/uvcpp_h2_session.cpp:1250-1256 cd15d5a39dc61848 9ec3f4c602e73a0a 48d033810df113d5 +src/http2/uvcpp_h2_session.cpp:1256-1256 9ec3f4c602e73a0a 9ec3f4c602e73a0a - +src/http2/uvcpp_h2_session.cpp:1366-1366 b1e5239df8d0f29d b1e5239df8d0f29d - +src/http2/uvcpp_h2_session.cpp:1739-1739 fec5526e48281d9a fec5526e48281d9a - src/http2/uvcpp_h2_session.cpp:217-217 18f9128271eb71ab 18f9128271eb71ab - src/http2/uvcpp_h2_session.cpp:234-234 ee8859e452fea4f4 ee8859e452fea4f4 - src/http2/uvcpp_h2_session.cpp:360-360 e4ce298e0aeea921 e4ce298e0aeea921 - @@ -256,7 +263,6 @@ src/http2/uvcpp_h2_session.cpp:948-948 6b031e8b38187821 6b031e8b38187821 - src/http2/uvcpp_h2_session.cpp:953-953 dc81b2d688a642fb dc81b2d688a642fb - src/http2/uvcpp_h2_session.cpp:977-977 61375cd9d0efa8bb 61375cd9d0efa8bb - src/http2/uvcpp_h2_session.cpp:988-988 fe1a925a7211114c fe1a925a7211114c - -src/http2/uvcpp_h2_session.cpp:994-994 ffe6316c076fe7ee ffe6316c076fe7ee - src/http2/uvcpp_h2_session.h:122-126 8259e3e59851b3c7 0df7525619834ee1 784b7fe66b4fe066 src/http2/uvcpp_h2_session.h:155-161 4114d12aeaa34eaa ace08267655265b2 562c5b89e162f7fc src/http2/uvcpp_h2_session.h:191-203 a6b688718f5ac0c1 562c5b89e162f7fc 0202eebe20a1b1a5 @@ -291,10 +297,10 @@ src/http3/uvcpp_h3_connection.h:1-22 baefa51e8402a630 2f92f71c8631781b dd4effc43 src/http3/uvcpp_h3_connection.h:113-113 f54dbea2a67d09ae f54dbea2a67d09ae - src/http3/uvcpp_h3_connection.h:145-145 0e88580a566c9c9f 0e88580a566c9c9f - src/http3/uvcpp_h3_connection.h:287-287 572c571054f39928 572c571054f39928 - -src/http3/uvcpp_h3_connection.h:480-480 8caa7bfb8317b7e6 8caa7bfb8317b7e6 - +src/http3/uvcpp_h3_connection.h:490-490 8caa7bfb8317b7e6 8caa7bfb8317b7e6 - src/http3/uvcpp_h3_connection.h:76-76 9b03d9b65861ee38 9b03d9b65861ee38 - src/http3/uvcpp_h3_session.h:108-108 f62d2312011db710 f62d2312011db710 - -src/http3/uvcpp_h3_session.h:315-315 3a3f70a5cbf75467 3a3f70a5cbf75467 - +src/http3/uvcpp_h3_session.h:338-338 3a3f70a5cbf75467 3a3f70a5cbf75467 - src/net/uvcpp_loop_worker.cpp:163-164 a30079b2ab8fb170 c06ba5ed2075ded7 227ec6f6e8fa6a31 src/net/uvcpp_loop_worker.h:155-155 e6d668cfa580ccf9 e6d668cfa580ccf9 - src/net/uvcpp_loop_worker.h:75-75 0f4741f79cc585c3 0f4741f79cc585c3 - @@ -380,8 +386,8 @@ src/quic/uvcpp_quic_connection.h:127-127 2cd3711e51e3a326 2cd3711e51e3a326 - src/quic/uvcpp_quic_connection.h:360-360 e7863cf2dbbcc5d0 e7863cf2dbbcc5d0 - src/quic/uvcpp_quic_connection.h:79-79 3e1bf5da37365106 3e1bf5da37365106 - src/quic/uvcpp_quic_server.h:65-65 7a0c7bfbafc8a583 7a0c7bfbafc8a583 - -src/quic/uvcpp_quic_session.cpp:1192-1192 4510c34329d332f4 4510c34329d332f4 - -src/quic/uvcpp_quic_session.cpp:143-143 b76c0bdc90c14594 b76c0bdc90c14594 - +src/quic/uvcpp_quic_session.cpp:1259-1259 4510c34329d332f4 4510c34329d332f4 - +src/quic/uvcpp_quic_session.cpp:144-144 b76c0bdc90c14594 b76c0bdc90c14594 - src/req/uvcpp_req.cpp:105-105 ee4859a5a93faa4f ee4859a5a93faa4f - src/req/uvcpp_req.cpp:25-25 3e5dc8e43a5d7d70 3e5dc8e43a5d7d70 - src/req/uvcpp_req.h:137-137 07d18821893c9abc 07d18821893c9abc - @@ -404,25 +410,25 @@ src/ssl/uvcpp_ssl.h:100-100 0d218d75a5a85b98 0d218d75a5a85b98 - src/ssl/uvcpp_ssl.h:17-17 e3afebbc8dd690a0 e3afebbc8dd690a0 - src/ssl/uvcpp_ssl.h:33-33 a9f32c9d1b61bbbe a9f32c9d1b61bbbe - src/ssl/uvcpp_ssl.h:90-98 d78c76cac382603d 757b866904eba7fd e321a6d0257565b9 -src/ssl/uvcpp_ssl_common.h:100-100 99a6434ade443687 99a6434ade443687 - +src/ssl/uvcpp_ssl_common.h:104-107 196597d4de2abce3 da565554c4844967 3af869fb540d21bd +src/ssl/uvcpp_ssl_common.h:110-110 99a6434ade443687 99a6434ade443687 - src/ssl/uvcpp_ssl_common.h:14-14 e3afebbc8dd690a0 e3afebbc8dd690a0 - src/ssl/uvcpp_ssl_common.h:30-35 b92f221e204e8180 479fc7c06b96a0ac d4087f3751461fc9 src/ssl/uvcpp_ssl_common.h:50-63 714521e977c77d7d 8f8cf7b9fbd36291 78830702e48db49a -src/ssl/uvcpp_ssl_common.h:94-97 196597d4de2abce3 da565554c4844967 3af869fb540d21bd src/ssl/uvcpp_ssl_context.cpp:146-164 128232f0636b9c62 da39a3ee5e6b4b0d c2b7df6201fdd336 src/ssl/uvcpp_ssl_context.cpp:147-149 97e6232a82d363a1 c4901e5d6b172388 42aa615d6dd94863 src/ssl/uvcpp_ssl_context.cpp:172-186 8130fa8a8c34544f 1c2a610ccaae3a28 8397793a6b19f927 src/ssl/uvcpp_ssl_context.cpp:197-197 1d8b272291c07c52 1d8b272291c07c52 - src/ssl/uvcpp_ssl_context.cpp:250-250 9b7b08a30487ede3 9b7b08a30487ede3 - src/ssl/uvcpp_ssl_context.cpp:56-56 bce9f140221a7a51 bce9f140221a7a51 - -src/ssl/uvcpp_ssl_context.cpp:643-643 ccbd47597d3b8ec9 ccbd47597d3b8ec9 - +src/ssl/uvcpp_ssl_context.cpp:620-620 0f8396b6aa75e591 0f8396b6aa75e591 - src/ssl/uvcpp_ssl_context.cpp:79-79 be1132262181b1b7 be1132262181b1b7 - src/ssl/uvcpp_ssl_context.h:139-139 3d026facd7fd1430 3d026facd7fd1430 - src/ssl/uvcpp_ssl_context.h:18-18 e3afebbc8dd690a0 e3afebbc8dd690a0 - -src/ssl/uvcpp_ssl_context.h:187-189 ea01d8f31f0fac9a db409413133ba3e2 c2364381fbe03733 -src/ssl/uvcpp_ssl_context.h:227-233 a2d2d7f96ec41aef 0f4283e1f5364d2a 47960d268fe1fe29 +src/ssl/uvcpp_ssl_context.h:189-195 2457904a694dc3be 350fe76d18e06a29 d94cd67d1f058580 +src/ssl/uvcpp_ssl_context.h:234-240 a2d2d7f96ec41aef 0f4283e1f5364d2a 47960d268fe1fe29 src/ssl/uvcpp_ssl_context.h:27-27 e10309625eca914e e10309625eca914e - -src/ssl/uvcpp_ssl_context.h:284-284 1ceb8023f9545958 1ceb8023f9545958 - +src/ssl/uvcpp_ssl_context.h:295-295 4fe82958caf8f9db 4fe82958caf8f9db - src/ssl/uvcpp_ssl_context.h:33-33 80f59c83737c4642 80f59c83737c4642 - src/ssl/uvcpp_ssl_context.h:36-36 84f1b71ee2308b4c 84f1b71ee2308b4c - src/ssl/uvcpp_ssl_context.h:39-39 6c2e2d0ddc8a2ded 6c2e2d0ddc8a2ded - @@ -514,7 +520,7 @@ src/web/uvcpp_http_compress.h:112-112 5e2581250eaba8f7 5e2581250eaba8f7 - src/web/uvcpp_http_compress.h:160-160 b57f77b669b471da b57f77b669b471da - src/web/uvcpp_http_date.cpp:114-124 3a0c004dfb16ee45 c2b7df6201fdd336 cf8b867126d74138 src/web/uvcpp_http_date.cpp:86-107 23acb02af9c64474 c2b7df6201fdd336 cc6e8e969c01b9d0 -src/web/uvcpp_http_parser.cpp:430-478 36c72595b65f436f c2b7df6201fdd336 34e8729861e457ab +src/web/uvcpp_http_parser.cpp:433-493 7a4fddbdd45ab607 c2b7df6201fdd336 34e8729861e457ab src/web/uvcpp_http_request.cpp:156-159 1ac3a55d3bffca60 48d033810df113d5 bfb843b8802acfe7 src/web/uvcpp_http_request.cpp:25-36 caad271b3be84e0c 7d54a26196a5f242 3b6e43f763d852af src/web/uvcpp_http_request.h:170-170 414fc2230e038037 414fc2230e038037 - @@ -527,101 +533,100 @@ src/web/uvcpp_http_response.h:202-202 97e67d4e228ea020 97e67d4e228ea020 - src/web/uvcpp_http_response.h:40-40 5d21b46f18af0b31 5d21b46f18af0b31 - src/web/uvcpp_http_response.h:52-56 4ce66406b67bf547 3cd9bb4fdab40ea8 fe1c52171c59a348 src/web/uvcpp_http_response.h:59-65 69c517704603643e 8f07fe0c931c8d1e af36fe17ba278502 -src/web/uvcpp_http_server.cpp:1035-1035 876b171fff7eedbf 876b171fff7eedbf - -src/web/uvcpp_http_server.cpp:1045-1046 d9c81826458399cb 72780eefbe30a9df 1dbf07b84013f991 -src/web/uvcpp_http_server.cpp:1058-1069 988f2cef88308082 48d033810df113d5 e266bf187351d458 -src/web/uvcpp_http_server.cpp:1072-1095 251d80c82d64ef19 8266c409522e1403 ce9771c8137dbe42 -src/web/uvcpp_http_server.cpp:1098-1114 0f8bcff4f2455d37 8266c409522e1403 54239fdc2566a328 -src/web/uvcpp_http_server.cpp:1108-1108 8dbaf26a76105b6f 8dbaf26a76105b6f - -src/web/uvcpp_http_server.cpp:1115-1191 d54f9a12fa06cefb e266bf187351d458 769c544579cb5177 -src/web/uvcpp_http_server.cpp:1164-1175 8a820eba6575591d 6b4ed2d2f4e1b651 d14cbef943403f77 -src/web/uvcpp_http_server.cpp:1196-1211 bd09e94e87d651e0 e266bf187351d458 4a9be13b046e76d1 -src/web/uvcpp_http_server.cpp:1210-1210 4a9be13b046e76d1 4a9be13b046e76d1 - -src/web/uvcpp_http_server.cpp:1323-1339 cce07ef58750c70b 48d033810df113d5 68a49f37693e2716 -src/web/uvcpp_http_server.cpp:1365-1366 a09e7c9adb1d9f15 e6bb714897ff952b 9af16ca3d347ef83 -src/web/uvcpp_http_server.cpp:1375-1384 ebd5427c42a3dec9 48d033810df113d5 631c8a05abecdaf3 -src/web/uvcpp_http_server.cpp:1458-1459 36653898ab54b4c3 8c72e5f3addfc359 e5daa1ca9e5ae28d -src/web/uvcpp_http_server.cpp:1497-1497 1564c2be8e6f52f8 1564c2be8e6f52f8 - -src/web/uvcpp_http_server.cpp:1545-1550 d95116292dd54c55 48d033810df113d5 aa5d5e4c7168d971 -src/web/uvcpp_http_server.cpp:1556-1557 420c79c39b7dd9a0 350f392992e38f9d 8da12a3921c7f41f -src/web/uvcpp_http_server.cpp:1565-1570 5308f1710e3340ad 5866b7533a095cd1 4acfeffc7dc8a65e -src/web/uvcpp_http_server.cpp:1580-1585 ab2a3976517a9668 9ff68dd36ccf1142 5d8ef439f521baf0 -src/web/uvcpp_http_server.cpp:1588-1600 ec3319ba4222147b c2b7df6201fdd336 db4c42e332721502 -src/web/uvcpp_http_server.cpp:1648-1658 5ff10334cd8d38fb 48d033810df113d5 253a3f491f721665 -src/web/uvcpp_http_server.cpp:1664-1664 11b09ac7d34866a9 11b09ac7d34866a9 - -src/web/uvcpp_http_server.cpp:1716-1730 8c7c87920bb86659 da39a3ee5e6b4b0d 48d033810df113d5 -src/web/uvcpp_http_server.cpp:1719-1719 d8716acf24e21f9a d8716acf24e21f9a - -src/web/uvcpp_http_server.cpp:1720-1723 5db658a1fd2d72f6 0f14f4db76cda696 b433283beac72745 -src/web/uvcpp_http_server.cpp:1816-1823 df057d0b7f3a1897 48d033810df113d5 c4435dec0c6b2a13 -src/web/uvcpp_http_server.cpp:1833-1838 7bf5c2bc0dfd53a4 48d033810df113d5 c4435dec0c6b2a13 -src/web/uvcpp_http_server.cpp:1845-1850 d4bcc0080519e182 31e8d51c3874db58 cfff9a1771f4f281 -src/web/uvcpp_http_server.cpp:1864-1864 11b09ac7d34866a9 11b09ac7d34866a9 - -src/web/uvcpp_http_server.cpp:1897-1897 f32952b1152c5ac9 f32952b1152c5ac9 - -src/web/uvcpp_http_server.cpp:1932-1932 11517ff144a8a29b 11517ff144a8a29b - -src/web/uvcpp_http_server.cpp:1961-1961 23d59723485f6682 23d59723485f6682 - -src/web/uvcpp_http_server.cpp:2039-2049 8d0998cdafbf47e9 605003430a6bb58a 3bc62c5a71f0b594 -src/web/uvcpp_http_server.cpp:2110-2110 06bd7f859e96a450 06bd7f859e96a450 - -src/web/uvcpp_http_server.cpp:2253-2256 02746fe900c490bd 2aeedf1df4fcc7b0 10b51d0740f979b8 -src/web/uvcpp_http_server.cpp:2254-2254 7d6ff498a5905867 7d6ff498a5905867 - -src/web/uvcpp_http_server.cpp:2332-2332 442405456b76790c 442405456b76790c - -src/web/uvcpp_http_server.cpp:2515-2517 ff86d405a49a1611 ac48c4655c6e5c4b fee3d98a68cc1da4 -src/web/uvcpp_http_server.cpp:281-283 183c1c3c6440adc2 c2b7df6201fdd336 18674d3dbf463e08 -src/web/uvcpp_http_server.cpp:3025-3025 7da7f5dd152ca84b 7da7f5dd152ca84b - -src/web/uvcpp_http_server.cpp:3055-3064 52d938b1b195b84e e266bf187351d458 be5aa7a51de26195 -src/web/uvcpp_http_server.cpp:3070-3070 26cff103a420234e 26cff103a420234e - -src/web/uvcpp_http_server.cpp:3075-3075 e652a9b02282fedb e652a9b02282fedb - -src/web/uvcpp_http_server.cpp:3098-3099 c2decf99cf2c665d 505dc7916bf5b448 7da7fb86e2d402c5 -src/web/uvcpp_http_server.cpp:3158-3158 21871b8cf1bf3fae 21871b8cf1bf3fae - -src/web/uvcpp_http_server.cpp:3165-3165 3519b99c8268f5e2 3519b99c8268f5e2 - -src/web/uvcpp_http_server.cpp:3168-3168 b69e24ce97dd4262 b69e24ce97dd4262 - -src/web/uvcpp_http_server.cpp:3249-3249 ae7b2b05807f2fe6 ae7b2b05807f2fe6 - -src/web/uvcpp_http_server.cpp:3260-3260 11b09ac7d34866a9 11b09ac7d34866a9 - -src/web/uvcpp_http_server.cpp:3268-3276 07d173d5fb93cbe8 dfb9fbb77de8bce5 876861fb7b901fd1 -src/web/uvcpp_http_server.cpp:379-381 c896eee1e3820aa0 1440817d6de09b5e 4dee8f3cefed4c7a -src/web/uvcpp_http_server.cpp:509-514 7782b0821171b8c0 e266bf187351d458 88b1c9d1d4bf5aea -src/web/uvcpp_http_server.cpp:640-641 2fd52bdcc1623764 be35b9f26be4def3 58a55c6ce8d2bd36 -src/web/uvcpp_http_server.cpp:640-669 082b52cc0bed0408 c2b7df6201fdd336 9cadb608c32cf380 -src/web/uvcpp_http_server.cpp:943-943 f38e455495037c88 f38e455495037c88 - -src/web/uvcpp_http_server.cpp:943-945 390e1a5e08711310 c2b7df6201fdd336 399398eead2f5456 -src/web/uvcpp_http_server.cpp:961-961 db324bd3454df1f5 db324bd3454df1f5 - -src/web/uvcpp_http_server.cpp:971-994 c1cb095526a071cb c2b7df6201fdd336 c6ee75053daff6b6 -src/web/uvcpp_http_server.cpp:996-1015 5493484dcc557eda c2b7df6201fdd336 c8e3120cbd475746 -src/web/uvcpp_http_server.cpp:998-1001 d0192b315ebc354a a53a3c17c86b1b5d 2deef53822caaa2b -src/web/uvcpp_http_server.h:1091-1130 d53680cb07c76c81 fdcb9cee394bf83b f88406e76781d90e -src/web/uvcpp_http_server.h:119-121 2ce1f9bd40acddfb 115b66c95c75ddac 0dca448b5962ef0c -src/web/uvcpp_http_server.h:126-128 967970b4c77d8ff5 3c7fb33ab1568429 dc5d59006e8f42c6 -src/web/uvcpp_http_server.h:1425-1425 64221c87af878ff1 64221c87af878ff1 - -src/web/uvcpp_http_server.h:1454-1457 53a827eb25940c7b 4be2332730056216 32fc28385f016160 -src/web/uvcpp_http_server.h:163-172 4b11a1f7c27ca315 0df7525619834ee1 17bd1a9cbdbe3f4f -src/web/uvcpp_http_server.h:1750-1750 9fe260c69bbbd619 9fe260c69bbbd619 - -src/web/uvcpp_http_server.h:1799-1801 ddac3066694e5baa 34a21dc66e42af70 09aa7ab70de871f9 -src/web/uvcpp_http_server.h:1803-1813 bf89289e2d4d65c3 cf1ebad7c0f55bad 8f07fe0c931c8d1e -src/web/uvcpp_http_server.h:1844-1844 af81d86a0a99c3c5 af81d86a0a99c3c5 - +src/web/uvcpp_http_server.cpp:1015-1015 db324bd3454df1f5 db324bd3454df1f5 - +src/web/uvcpp_http_server.cpp:1025-1048 c1cb095526a071cb c2b7df6201fdd336 c6ee75053daff6b6 +src/web/uvcpp_http_server.cpp:1050-1069 5493484dcc557eda c2b7df6201fdd336 c8e3120cbd475746 +src/web/uvcpp_http_server.cpp:1052-1055 d0192b315ebc354a a53a3c17c86b1b5d 2deef53822caaa2b +src/web/uvcpp_http_server.cpp:1089-1089 876b171fff7eedbf 876b171fff7eedbf - +src/web/uvcpp_http_server.cpp:1099-1100 d9c81826458399cb 72780eefbe30a9df 1dbf07b84013f991 +src/web/uvcpp_http_server.cpp:1112-1123 988f2cef88308082 48d033810df113d5 e266bf187351d458 +src/web/uvcpp_http_server.cpp:1126-1149 251d80c82d64ef19 8266c409522e1403 ce9771c8137dbe42 +src/web/uvcpp_http_server.cpp:1152-1168 0f8bcff4f2455d37 8266c409522e1403 54239fdc2566a328 +src/web/uvcpp_http_server.cpp:1162-1162 8dbaf26a76105b6f 8dbaf26a76105b6f - +src/web/uvcpp_http_server.cpp:1169-1245 d54f9a12fa06cefb e266bf187351d458 769c544579cb5177 +src/web/uvcpp_http_server.cpp:1218-1229 8a820eba6575591d 6b4ed2d2f4e1b651 d14cbef943403f77 +src/web/uvcpp_http_server.cpp:1250-1265 bd09e94e87d651e0 e266bf187351d458 4a9be13b046e76d1 +src/web/uvcpp_http_server.cpp:1264-1264 4a9be13b046e76d1 4a9be13b046e76d1 - +src/web/uvcpp_http_server.cpp:1427-1443 cce07ef58750c70b 48d033810df113d5 68a49f37693e2716 +src/web/uvcpp_http_server.cpp:1469-1470 a09e7c9adb1d9f15 e6bb714897ff952b 9af16ca3d347ef83 +src/web/uvcpp_http_server.cpp:1479-1488 ebd5427c42a3dec9 48d033810df113d5 631c8a05abecdaf3 +src/web/uvcpp_http_server.cpp:1562-1563 36653898ab54b4c3 8c72e5f3addfc359 e5daa1ca9e5ae28d +src/web/uvcpp_http_server.cpp:1624-1624 1564c2be8e6f52f8 1564c2be8e6f52f8 - +src/web/uvcpp_http_server.cpp:1672-1677 d95116292dd54c55 48d033810df113d5 aa5d5e4c7168d971 +src/web/uvcpp_http_server.cpp:1683-1684 420c79c39b7dd9a0 350f392992e38f9d 8da12a3921c7f41f +src/web/uvcpp_http_server.cpp:1692-1697 5308f1710e3340ad 5866b7533a095cd1 4acfeffc7dc8a65e +src/web/uvcpp_http_server.cpp:1707-1712 ab2a3976517a9668 9ff68dd36ccf1142 5d8ef439f521baf0 +src/web/uvcpp_http_server.cpp:1715-1727 ec3319ba4222147b c2b7df6201fdd336 db4c42e332721502 +src/web/uvcpp_http_server.cpp:1775-1785 5ff10334cd8d38fb 48d033810df113d5 253a3f491f721665 +src/web/uvcpp_http_server.cpp:1791-1791 11b09ac7d34866a9 11b09ac7d34866a9 - +src/web/uvcpp_http_server.cpp:1843-1857 8c7c87920bb86659 da39a3ee5e6b4b0d 48d033810df113d5 +src/web/uvcpp_http_server.cpp:1846-1846 d8716acf24e21f9a d8716acf24e21f9a - +src/web/uvcpp_http_server.cpp:1847-1850 5db658a1fd2d72f6 0f14f4db76cda696 b433283beac72745 +src/web/uvcpp_http_server.cpp:1943-1950 df057d0b7f3a1897 48d033810df113d5 c4435dec0c6b2a13 +src/web/uvcpp_http_server.cpp:1960-1965 7bf5c2bc0dfd53a4 48d033810df113d5 c4435dec0c6b2a13 +src/web/uvcpp_http_server.cpp:1972-1977 d4bcc0080519e182 31e8d51c3874db58 cfff9a1771f4f281 +src/web/uvcpp_http_server.cpp:1991-1991 11b09ac7d34866a9 11b09ac7d34866a9 - +src/web/uvcpp_http_server.cpp:2024-2024 f32952b1152c5ac9 f32952b1152c5ac9 - +src/web/uvcpp_http_server.cpp:2059-2059 11517ff144a8a29b 11517ff144a8a29b - +src/web/uvcpp_http_server.cpp:2088-2088 23d59723485f6682 23d59723485f6682 - +src/web/uvcpp_http_server.cpp:2166-2176 8d0998cdafbf47e9 605003430a6bb58a 3bc62c5a71f0b594 +src/web/uvcpp_http_server.cpp:2237-2237 06bd7f859e96a450 06bd7f859e96a450 - +src/web/uvcpp_http_server.cpp:2380-2383 02746fe900c490bd 2aeedf1df4fcc7b0 10b51d0740f979b8 +src/web/uvcpp_http_server.cpp:2381-2381 7d6ff498a5905867 7d6ff498a5905867 - +src/web/uvcpp_http_server.cpp:2459-2459 442405456b76790c 442405456b76790c - +src/web/uvcpp_http_server.cpp:2642-2644 ff86d405a49a1611 ac48c4655c6e5c4b fee3d98a68cc1da4 +src/web/uvcpp_http_server.cpp:3152-3152 7da7f5dd152ca84b 7da7f5dd152ca84b - +src/web/uvcpp_http_server.cpp:3182-3191 52d938b1b195b84e e266bf187351d458 be5aa7a51de26195 +src/web/uvcpp_http_server.cpp:3197-3197 26cff103a420234e 26cff103a420234e - +src/web/uvcpp_http_server.cpp:3202-3202 e652a9b02282fedb e652a9b02282fedb - +src/web/uvcpp_http_server.cpp:3225-3226 c2decf99cf2c665d 505dc7916bf5b448 7da7fb86e2d402c5 +src/web/uvcpp_http_server.cpp:3285-3285 21871b8cf1bf3fae 21871b8cf1bf3fae - +src/web/uvcpp_http_server.cpp:329-331 183c1c3c6440adc2 c2b7df6201fdd336 18674d3dbf463e08 +src/web/uvcpp_http_server.cpp:3292-3292 3519b99c8268f5e2 3519b99c8268f5e2 - +src/web/uvcpp_http_server.cpp:3295-3295 b69e24ce97dd4262 b69e24ce97dd4262 - +src/web/uvcpp_http_server.cpp:3376-3376 ae7b2b05807f2fe6 ae7b2b05807f2fe6 - +src/web/uvcpp_http_server.cpp:3387-3387 11b09ac7d34866a9 11b09ac7d34866a9 - +src/web/uvcpp_http_server.cpp:3395-3403 07d173d5fb93cbe8 dfb9fbb77de8bce5 876861fb7b901fd1 +src/web/uvcpp_http_server.cpp:427-429 c896eee1e3820aa0 1440817d6de09b5e 4dee8f3cefed4c7a +src/web/uvcpp_http_server.cpp:557-562 7782b0821171b8c0 e266bf187351d458 88b1c9d1d4bf5aea +src/web/uvcpp_http_server.cpp:688-689 2fd52bdcc1623764 be35b9f26be4def3 58a55c6ce8d2bd36 +src/web/uvcpp_http_server.cpp:688-717 082b52cc0bed0408 c2b7df6201fdd336 9cadb608c32cf380 +src/web/uvcpp_http_server.cpp:991-991 f38e455495037c88 f38e455495037c88 - +src/web/uvcpp_http_server.cpp:991-993 390e1a5e08711310 c2b7df6201fdd336 399398eead2f5456 +src/web/uvcpp_http_server.h:1111-1150 d53680cb07c76c81 fdcb9cee394bf83b f88406e76781d90e +src/web/uvcpp_http_server.h:133-135 967970b4c77d8ff5 3c7fb33ab1568429 dc5d59006e8f42c6 +src/web/uvcpp_http_server.h:1452-1452 64221c87af878ff1 64221c87af878ff1 - +src/web/uvcpp_http_server.h:1481-1484 53a827eb25940c7b 4be2332730056216 32fc28385f016160 +src/web/uvcpp_http_server.h:170-179 4b11a1f7c27ca315 0df7525619834ee1 17bd1a9cbdbe3f4f +src/web/uvcpp_http_server.h:1777-1777 9fe260c69bbbd619 9fe260c69bbbd619 - +src/web/uvcpp_http_server.h:1830-1832 ddac3066694e5baa 34a21dc66e42af70 09aa7ab70de871f9 +src/web/uvcpp_http_server.h:1834-1844 bf89289e2d4d65c3 cf1ebad7c0f55bad 8f07fe0c931c8d1e +src/web/uvcpp_http_server.h:1875-1875 af81d86a0a99c3c5 af81d86a0a99c3c5 - src/web/uvcpp_http_server.h:19-19 19cc786362fbd4b3 19cc786362fbd4b3 - -src/web/uvcpp_http_server.h:1906-1906 9598a031e52a7f6b 9598a031e52a7f6b - -src/web/uvcpp_http_server.h:1945-1945 fc7fb4fab5c8a487 fc7fb4fab5c8a487 - -src/web/uvcpp_http_server.h:1946-1949 7ff55234a81d4f60 da73ac036371eeb2 88b7e7def575ee76 -src/web/uvcpp_http_server.h:1963-1963 200efe520a721a79 200efe520a721a79 - -src/web/uvcpp_http_server.h:1974-1974 75a793a164eb411b 75a793a164eb411b - -src/web/uvcpp_http_server.h:1978-1978 8f096851286e58b4 8f096851286e58b4 - -src/web/uvcpp_http_server.h:218-218 3b66a21918295b88 3b66a21918295b88 - -src/web/uvcpp_http_server.h:220-220 2eae3050819bd471 2eae3050819bd471 - -src/web/uvcpp_http_server.h:270-270 ca9da7495bdf7da9 ca9da7495bdf7da9 - -src/web/uvcpp_http_server.h:355-355 99d8638604a9e305 99d8638604a9e305 - -src/web/uvcpp_http_server.h:357-357 9d5f8687c4e51ea3 9d5f8687c4e51ea3 - -src/web/uvcpp_http_server.h:417-420 4d4aaae57f1331d1 82e9af9b0b9975cb 625b54bce9a3139a -src/web/uvcpp_http_server.h:445-445 90937352e8467c21 90937352e8467c21 - -src/web/uvcpp_http_server.h:499-499 350b4b93f1c27df9 350b4b93f1c27df9 - -src/web/uvcpp_http_server.h:502-535 fb2ee2b13e7a3723 ca931cab1213adf0 7afffe01eff66900 -src/web/uvcpp_http_server.h:555-560 c77fccf5e37d1d4a a4ace7b339dd2f33 0cd40f0c83ec26a9 -src/web/uvcpp_http_server.h:565-568 bbadbe4a28da029b de402ee05d10c9f9 e28547faa03f369f -src/web/uvcpp_http_server.h:651-651 ef0cbc45c23507ad ef0cbc45c23507ad - -src/web/uvcpp_http_server.h:716-729 0c0f773b7cc02589 8609acd9c956ace9 e6fad70d6e7f8534 -src/web/uvcpp_http_server.h:768-815 0aba404645bf1e1a 8f07fe0c931c8d1e 6ddfd80bb97ea8e7 -src/web/uvcpp_http_server.h:771-794 c8d9516ff65b5812 93d6a7c8bf454b4f 2a38d5f8179f5ca0 -src/web/uvcpp_http_server.h:848-848 2f7c5b60895ec29e 2f7c5b60895ec29e - -src/web/uvcpp_http_server.h:894-894 3884a289e1e9b79b 3884a289e1e9b79b - -src/web/uvcpp_http_server.h:897-897 8cd9a1f16841b592 8cd9a1f16841b592 - +src/web/uvcpp_http_server.h:1937-1937 9598a031e52a7f6b 9598a031e52a7f6b - +src/web/uvcpp_http_server.h:1976-1976 fc7fb4fab5c8a487 fc7fb4fab5c8a487 - +src/web/uvcpp_http_server.h:1977-1980 7ff55234a81d4f60 da73ac036371eeb2 88b7e7def575ee76 +src/web/uvcpp_http_server.h:1994-1994 200efe520a721a79 200efe520a721a79 - +src/web/uvcpp_http_server.h:2005-2005 75a793a164eb411b 75a793a164eb411b - +src/web/uvcpp_http_server.h:2009-2009 8f096851286e58b4 8f096851286e58b4 - +src/web/uvcpp_http_server.h:225-225 3b66a21918295b88 3b66a21918295b88 - +src/web/uvcpp_http_server.h:227-227 2eae3050819bd471 2eae3050819bd471 - +src/web/uvcpp_http_server.h:277-277 ca9da7495bdf7da9 ca9da7495bdf7da9 - +src/web/uvcpp_http_server.h:362-362 99d8638604a9e305 99d8638604a9e305 - +src/web/uvcpp_http_server.h:364-364 9d5f8687c4e51ea3 9d5f8687c4e51ea3 - +src/web/uvcpp_http_server.h:424-427 4d4aaae57f1331d1 82e9af9b0b9975cb 625b54bce9a3139a +src/web/uvcpp_http_server.h:452-452 90937352e8467c21 90937352e8467c21 - +src/web/uvcpp_http_server.h:519-519 350b4b93f1c27df9 350b4b93f1c27df9 - +src/web/uvcpp_http_server.h:522-555 fb2ee2b13e7a3723 ca931cab1213adf0 7afffe01eff66900 +src/web/uvcpp_http_server.h:575-580 c77fccf5e37d1d4a a4ace7b339dd2f33 0cd40f0c83ec26a9 +src/web/uvcpp_http_server.h:585-588 bbadbe4a28da029b de402ee05d10c9f9 e28547faa03f369f +src/web/uvcpp_http_server.h:671-671 ef0cbc45c23507ad ef0cbc45c23507ad - +src/web/uvcpp_http_server.h:736-749 0c0f773b7cc02589 8609acd9c956ace9 e6fad70d6e7f8534 +src/web/uvcpp_http_server.h:788-835 0aba404645bf1e1a 8f07fe0c931c8d1e 6ddfd80bb97ea8e7 +src/web/uvcpp_http_server.h:791-814 c8d9516ff65b5812 93d6a7c8bf454b4f 2a38d5f8179f5ca0 +src/web/uvcpp_http_server.h:868-868 2f7c5b60895ec29e 2f7c5b60895ec29e - +src/web/uvcpp_http_server.h:914-914 3884a289e1e9b79b 3884a289e1e9b79b - +src/web/uvcpp_http_server.h:917-917 8cd9a1f16841b592 8cd9a1f16841b592 - src/web/uvcpp_static_server.cpp:321-339 406850a9c0be727f c2b7df6201fdd336 406e7d1a888a50f5 src/web/uvcpp_static_server.cpp:355-371 ff9677b2648b1aec c2b7df6201fdd336 c4b03298bd397a19 src/web/uvcpp_static_server.cpp:44-81 bd9f4d351d9cfb46 c2b7df6201fdd336 db4c42e332721502 @@ -682,25 +687,25 @@ src/web/uvcpp_ws_connection.cpp:119-119 b6ef97c9ef0602e3 b6ef97c9ef0602e3 - src/web/uvcpp_ws_connection.cpp:125-164 7a9e9cde4d0d3a41 c2b7df6201fdd336 b551ecd6117a0532 src/web/uvcpp_ws_connection.cpp:143-143 7d53cf6aa6f39699 7d53cf6aa6f39699 - src/web/uvcpp_ws_connection.cpp:146-146 7bb2b4bec768fde7 7bb2b4bec768fde7 - -src/web/uvcpp_ws_connection.cpp:231-231 82a3ad57e6e08815 82a3ad57e6e08815 - -src/web/uvcpp_ws_connection.cpp:251-251 b9020b27773ad173 b9020b27773ad173 - -src/web/uvcpp_ws_connection.cpp:252-252 7247feb3b8cbf9dd 7247feb3b8cbf9dd - -src/web/uvcpp_ws_connection.cpp:265-265 84a81f9ef224510b 84a81f9ef224510b - -src/web/uvcpp_ws_connection.cpp:267-267 09d4b26468ba0ff5 09d4b26468ba0ff5 - -src/web/uvcpp_ws_connection.cpp:295-295 6cb613bd36fdc75f 6cb613bd36fdc75f - -src/web/uvcpp_ws_connection.cpp:314-314 240257f670e27e30 240257f670e27e30 - -src/web/uvcpp_ws_connection.cpp:340-340 d94d863619ae61d1 d94d863619ae61d1 - -src/web/uvcpp_ws_connection.cpp:416-416 44e0ca9841603a01 44e0ca9841603a01 - +src/web/uvcpp_ws_connection.cpp:243-243 82a3ad57e6e08815 82a3ad57e6e08815 - +src/web/uvcpp_ws_connection.cpp:263-263 b9020b27773ad173 b9020b27773ad173 - +src/web/uvcpp_ws_connection.cpp:264-264 7247feb3b8cbf9dd 7247feb3b8cbf9dd - +src/web/uvcpp_ws_connection.cpp:277-277 84a81f9ef224510b 84a81f9ef224510b - +src/web/uvcpp_ws_connection.cpp:279-279 09d4b26468ba0ff5 09d4b26468ba0ff5 - +src/web/uvcpp_ws_connection.cpp:335-335 6cb613bd36fdc75f 6cb613bd36fdc75f - +src/web/uvcpp_ws_connection.cpp:354-354 240257f670e27e30 240257f670e27e30 - +src/web/uvcpp_ws_connection.cpp:380-380 d94d863619ae61d1 d94d863619ae61d1 - src/web/uvcpp_ws_connection.cpp:42-42 946704a597a007c7 946704a597a007c7 - -src/web/uvcpp_ws_connection.cpp:432-432 423daf1fc38d0c35 423daf1fc38d0c35 - -src/web/uvcpp_ws_connection.cpp:440-446 8efe6ac51b54218a a6a87cf16d8497bd da39a3ee5e6b4b0d -src/web/uvcpp_ws_connection.cpp:449-449 b62e916881c14ee1 b62e916881c14ee1 - src/web/uvcpp_ws_connection.cpp:45-58 81cab6657d41722a c2b7df6201fdd336 7bb2b4bec768fde7 -src/web/uvcpp_ws_connection.cpp:488-488 4aa5b5ba916fcc56 4aa5b5ba916fcc56 - -src/web/uvcpp_ws_connection.cpp:622-622 66e618bcd39607fc 66e618bcd39607fc - -src/web/uvcpp_ws_connection.cpp:717-717 ed8a4998950deaff ed8a4998950deaff - -src/web/uvcpp_ws_connection.cpp:721-721 0dd6c9d40af8999f 0dd6c9d40af8999f - -src/web/uvcpp_ws_connection.cpp:723-723 f0cf56cbafd71286 f0cf56cbafd71286 - +src/web/uvcpp_ws_connection.cpp:456-456 44e0ca9841603a01 44e0ca9841603a01 - +src/web/uvcpp_ws_connection.cpp:472-472 423daf1fc38d0c35 423daf1fc38d0c35 - +src/web/uvcpp_ws_connection.cpp:480-486 8efe6ac51b54218a a6a87cf16d8497bd da39a3ee5e6b4b0d +src/web/uvcpp_ws_connection.cpp:489-489 b62e916881c14ee1 b62e916881c14ee1 - +src/web/uvcpp_ws_connection.cpp:528-528 4aa5b5ba916fcc56 4aa5b5ba916fcc56 - +src/web/uvcpp_ws_connection.cpp:662-662 66e618bcd39607fc 66e618bcd39607fc - +src/web/uvcpp_ws_connection.cpp:757-757 ed8a4998950deaff ed8a4998950deaff - +src/web/uvcpp_ws_connection.cpp:757-764 8dbdefda73c3908a 48d033810df113d5 a4f64f9713307bfc +src/web/uvcpp_ws_connection.cpp:766-766 f0cf56cbafd71286 f0cf56cbafd71286 - src/web/uvcpp_ws_connection.h:10-23 3d813c4510f15690 c4d2345910e45855 d338759f69ca9599 src/web/uvcpp_ws_connection.h:169-169 d09f4b4b176afd28 d09f4b4b176afd28 - src/web/uvcpp_ws_connection.h:175-175 1f76f3341ebccb19 1f76f3341ebccb19 -