4 Commits

Author SHA1 Message Date
xfy911
f5563381b8 feat(cache): 实现 HTTP 缓存协商(ETag + Last-Modified + 304)
- static: 添加 format_http_time / generate_etag / match_etag / parse_http_time 辅助函数
- static: 静态文件服务生成 ETag(文件大小+修改时间)和 Last-Modified
- static: 实现 If-None-Match 和 If-Modified-Since 缓存协商,命中时返回 304 Not Modified
- http: 请求结构体添加 if_none_match / if_modified_since 字段
- http: 响应头格式化支持 ETag 和 Last-Modified 输出
- http: 重构响应头构建,先输出固定头再追加缓存头

测试验证:curl 带 If-None-Match / If-Modified-Since 均返回 304
2026-06-03 17:38:28 +08:00
xfy911
413288d837 feat(http): 添加缓存头部解析 + 修复编译警告
- http: 解析 If-None-Match 和 If-Modified-Since 请求头
- http: 响应结构体添加 etag 和 last_modified 字段
- server/static: 替换 strncpy 为 snprintf,消除 stringop-truncation 警告
- static: 修复 CSS 百分号转义(%%)
- static: 消除 unused parameter 警告
2026-06-03 17:30:37 +08:00
xfy911
250f336eff fix(build): 修复编译错误与警告
- Makefile: 添加 -luring 链接(coco 内部使用 io_uring)
- static.c: 添加 #include <time.h> 和 _GNU_SOURCE 定义
- http.h: 添加 #include <stddef.h> 修复 size_t 未定义
- server.c: 删除未使用的 conn_write,修复 root_dir 传递
2026-06-03 16:55:48 +08:00
xfy911
d7b9c93e78 feat(static): 实现静态资源服务模块
- static_serve_file: 文件服务(sendfile 零拷贝 + Range 支持)
- static_serve_directory: 目录浏览(HTML 列表 + 文件大小/时间)
- static_send_error: HTTP 错误响应(400/403/404/416/500)
- safe_path_join: 路径遍历防护
2026-06-03 16:45:48 +08:00