4.4 KiB
4.4 KiB
Task Spec: M-NET-01..05 — P2 Network Hardening, Native HTTP/1.1 Codec, Connection Pool, Safe Static Open & RFC 6455 WebSockets
- Branch:
feat/roadmap-p2-wave9(baselinemainat3e25405, building onVL-004/VL-005in66baae7+9920bfd). - Roadmap authority:
docs/roadmap/modules/Net.md(M-NET-01..M-NET-05),ARCHITECTURE.mdC-02..C-06, C-11, C-13. - Error domain:
Void::Result::kNetErrorDomain = 26(NetErrorCodeininclude/Void/Net/Http.hpp).
Scope & Deliverables
- Native Incremental HTTP/1.1 Codec (
include/Void/Net/HttpCodec.hpp,src/Net/HttpCodec.cpp):HttpCodecLimits(defaults:max_start_line_bytes = 8 KiB,max_header_bytes = 32 KiB,max_headers = 100,max_body_bytes = 8 MiB,max_chunk_ext_bytes = 1 KiB,max_trailer_bytes = 8 KiB).HttpRequestParserandHttpResponseParser: byte-by-byte / arbitrary-split incremental RFC 9110/9112 state machines.- Strict CRLF framing, header field-name token validation, rejection of duplicate/conflicting
Content-Length, rejection ofTransfer-Encoding+Content-Lengthsmuggling ambiguity, handling of1xxinformational responses,HEAD/204/304no-body responses, chunked transfer encoding with chunk extensions and trailers, close-delimited response bodies (finish_eof()), and explicitconnection_reusable()check.
- Bounded HTTP/1.1 Connection Pool (
include/Void/Net/Pool.hpp,src/Net/Pool.cpp):PoolLimits(defaults:max_total_connections = 256,max_per_origin = 8,max_idle_connections = 128,idle_timeout = 30s).PoolKeykeyed by{scheme, host, port, proxy_identity, tls_policy_generation}(so changing proxy or trust generation never reuses stale connections).ConnectionPoolusing injectableVoid::Time::MonotonicClockfor deterministic idle eviction, returning RAIIConnectionLeasehandles that only return clean, reusable connections to the pool (mark_reusable(true)); abandoned/unmarked/dirty/expired leases close cleanly.
- Descriptor-Pinned Static File Opening (
include/Void/Net/Server.hpp,src/Net/Server.cpp):OpenedStaticFile(move-only RAII descriptor +content_type+size,read_all(),native_handle()).StaticFileResolver::open_safe(std::string_view request_path)walking components beneath a retained root directory fd (O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC), rejecting symlinks/traversal/non-regular files without pathname TOCTOU.
- Redirect Compliance in
HttpClient(src/Net/Http.cpp):- Follow only
301,302,303,307,308;303converts non-HEAD toGETand strips body +Content-Length/Content-Type;307/308preserve method/body; resolve relativeLocationreferences against current URL; reject HTTPS->HTTP downgrade unlessallow_insecure_redirects; stripAuthorization,Cookie,Proxy-Authorization,X-Api-Keyon cross-origin hops; enforce single absolute steady deadline across redirect hops.
- Follow only
- Native RFC 6455 WebSocket Wire Framing & Loopback Transport (
include/Void/Net/WebSocket.hpp,src/Net/WebSocket.cpp,include/Void/Net/HttpServer.hpp,src/Net/HttpServer.cpp):compute_websocket_accept(key)(RFC 6455 SHA-1 + Base64),validate_websocket_upgrade_request()(version 13,Upgrade: websocket,Connection: Upgrade, 16-byte base64 key, optional origin/subprotocol policy).WebSocketOpcode,WebSocketLimits(max_message_bytes = 1 MiB,max_output_messages = 64,max_output_bytes = 4 MiB),WebSocketFrame,encode_websocket_frame(),WebSocketFrameDecoderenforcing client masking / server non-masking, fragmentation, control-frame rules (<= 125 bytes, FIN=1), strict RFC 3629 UTF-8 validation for text frames & close reasons, ping/pong, and single close handshake.HttpServer::add_websocket_route(pattern, WebSocketSessions&, WebSocketUpgradeOptions)upgrading incoming HTTP/1.1 requests into live RFC 6455 connections integrated withWebSocketSessions, plus loopbackWebSocketClientfor full client/server wire verification.
Verification
- Standalone
Net;Testing(-DVOID_WARNINGS_AS_ERRORS=ON): split-byte smuggling & chunked/trailer/1xx/HEAD codec corpus, pool eviction & key isolation,open_safesymlink-swap rejection, redirect303/307/relative/cross-origin tests, RFC 6455 wire & loopbackWebSocketClient/HttpServerping/pong/fragmented/UTF-8/close/shutdown tests. ctestNetOnlyinstalled consumer, fullRelWithDebInfo, DebugASan+UBSan, DebugTSan.