feat(http2): 实现 HTTP/2 静态文件服务
- http2.c: 新增 http2_serve_static(),支持 GET/HEAD 请求 - 支持 304 缓存协商(If-None-Match / If-Modified-Since) - 支持目录转 index.html、路径遍历防护 - 使用 nghttp2_data_provider 发送文件内容 - server.c: 创建 HTTP/2 会话后设置上下文(root_dir、压缩配置) - 新增 6 项 HTTP/2 集成测试(ALPN 协商、GET/HEAD/404、缓存) - 45 项集成测试 + 35 单元测试全部通过
This commit is contained in:
parent
88c6597748
commit
094ae103ee
6
server.c
6
server.c
@ -701,6 +701,12 @@ static void accept_loop(void *arg) {
|
|||||||
close(client_fd);
|
close(client_fd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
http2_session_t *h2 = http2_session_get(client_fd);
|
||||||
|
if (h2) {
|
||||||
|
http2_session_set_context(h2, ctx->config.root_dir,
|
||||||
|
ctx->config.gzip_enabled,
|
||||||
|
ctx->config.brotli_enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user