清理冗余路由代码,修复首页标题与模板安全

- 简化 http-api/http-tcp/web-toolkit 的 router.py,抽取重复代码
- 修复 ws-api middleware 中间件返回值传递问题
- 修复 web-toolkit template.py 安全漏洞 (eval → AST 验证)
- 将首页标题从 "OSS Runtime" 改为 "Future OSS"
- 更新 README.md 与 static/banner.svg
- 新增 i18n 国际化插件 (骨架)
- 新增 oss/shared/ 共享模块
This commit is contained in:
Falck
2026-04-06 12:40:49 +08:00
parent c881b1b8d1
commit f894e55602
29 changed files with 890 additions and 201 deletions

View File

@@ -77,8 +77,35 @@ class TcpHttpServer:
break
buffer += data
# 检查 HTTP 请求是否完整
# 检查 HTTP 请求是否完整
if b"\r\n\r\n" in buffer:
# 先解析请求头以获取 Content-Length
header_end = buffer.find(b"\r\n\r\n")
header_text = buffer[:header_end].decode("utf-8", errors="replace")
# 从请求头中提取 Content-Length
content_length = 0
for line in header_text.split("\r\n")[1:]:
if line.lower().startswith("content-length:"):
content_length = int(line.split(":", 1)[1].strip())
break
# 计算 body 起始位置
body_start_pos = header_end + 4 # \r\n\r\n
body_received = len(buffer) - body_start_pos
# 等待完整 body
if body_received < content_length:
# 继续接收剩余数据
while body_received < content_length:
remaining = content_length - body_received
chunk = client.conn.recv(min(4096, remaining))
if not chunk:
break
buffer += chunk
body_received += len(chunk)
# 现在解析完整请求
request = self._parse_request(buffer)
if request:
# 触发请求事件