v1.77.0 strengthens static-file confinement, fixes hijacked connection handling, and improves HTTP and cookie compatibility. It also adds an opt-in bounded stream reader, configurable body-buffer retention, and deadline support for adapted net/http handlers.
Static-file symlink behavior changes by default. The default OS-backed FS now rejects symlinks that leave Root or CompressRoot, as well as absolute symlinks even when their targets are inside the root. Relative symlinks that stay inside the root continue to work. Set FS.AllowSymlinksOutsideRoot to restore the previous behavior when external symlinks are intentional. Custom FS.FS implementations are unaffected. #2490
Security fixes and hardening
- Default static-file operations stay within their configured roots. File reads and compressed-cache operations use
os.Rootto prevent symlink traversal outsideRootandCompressRoot. Each root is confined independently; empty roots withAllowEmptyRootand whole-volume roots retain their existing behavior. #2490 - Custom filesystems no longer trigger unrelated disk deletions. A stale compressed file in a custom
FS.FSpreviously caused anos.Removecall using its filesystem-relative name, potentially deleting a matching file in the process working directory. Custom filesystems now regenerate stale compressed content in memory without removing a disk file. #2489 - Kept hijacked connections no longer depend on a recycled request context. With both
KeepHijackedConnsandReduceMemoryUsageenabled, the hijacked reader is detached from the context before the hijack handler runs. This prevents later reads from panicking or accessing another client's connection after context reuse. #2495
Features and resource management
- An opt-in stream reader bounds copied payload buffering.
NewBoundedStreamReaderworks withSetBodyStreamand applies backpressure when consumers fall behind. Active copied payload is limited to 160 KiB per bridge, or 320 KiB across the two bridges used by its bounded compression path. These limits exclude caller buffers, codecs, sockets, and other overhead; wrapping the reader loses the combined compression bound. ExistingNewStreamReaderandSetBodyStreamWriterbehavior is unchanged. #2488 - Request and response body buffers can be retained explicitly. The exported
Request.KeepBodyBufferandResponse.KeepBodyBufferfields preserve body buffers across resets for reuse. Releasing a request or response to the pool clears the retention setting. #2451 - Adapted handlers can configure connection deadlines.
RequestCtx.SetReadDeadlineandSetWriteDeadlineare also exposed throughfasthttpadaptor, enablinghttp.ResponseControllerdeadline calls. The adaptor still buffers the request body before invoking the handler, so a read deadline set inside an adapted handler cannot govern the preceding upload. #2452
HTTP compatibility and connection handling
- Weighted compression codings are recognized.
Accept-Encodingentries such asgzip;q=0.8now match, whileq=0makes a coding unacceptable. Matching remains case-insensitive and requires a complete coding token; quality-based preference ordering and wildcard matching are not added. #2491 - HTTP/1.0 clients no longer receive unsupported informational responses.
Expect: 100-continueis ignored for HTTP/1.0 requests, and103 Early Hintsis not sent to HTTP/1.0 clients. #2492, #2496 - Hijacking works with server keep-alive limits.
DisableKeepaliveand reachingMaxRequestsPerConnno longer suppress a registered hijack handler or add an unwantedConnection: closeto an upgrade response. Explicit connection-close requests and other existing close conditions still apply. #2494 - Pipe connection deadlines interrupt pending operations. Updating deadlines on
fasthttputil.PipeConnsnow affects blocked reads and writes, and write-deadline updates no longer race with writes. #2471 - Cookie parsing tolerates invalid attributes and handles names consistently. Invalid
Max-Ageattributes are ignored,Secure,HttpOnly, andPartitionedare recognized even with a value, and surrounding tabs are trimmed.Set-Cookievalues without=are stored under the same empty key returned byCookie.ParseBytes, keeping lookup and deletion consistent. #2497, #2498, #2500, #2501
Proxy authentication now uses decoded credentials in Proxy-Authorization, and static-file 416 Range Not Satisfiable responses include Content-Range. #2499, #2502
What's Changed
Security and hardening
- fix(fs): resolve default FS paths with os.Root so they stay inside Root by @Thanatos9404 in #2490
- fix(fs): don't remove stale compressed files of a custom FS.FS from disk by @Thanatos9404 in #2489
- fix: detach kept hijacked connections from the request context's reader by @h2zi in #2495
Features
- Add an opt-in bounded stream reader by @CSXizhang in #2488
- Export KeepBodyBuffer on Request and Response by @AdamMagued in #2451
- fasthttpadaptor: add support for ResponseController SetReadDeadline and SetWriteDeadline by @AdamMagued in #2452
Fixes
- fix: accept Accept-Encoding codings that carry a quality value by @ybai08 in #2491
- fix: ignore Expect: 100-continue in HTTP/1.0 requests by @LuisFigueroaG in #2492
- fix: don't send 103 Early Hints to HTTP/1.0 clients by @LuisFigueroaG in #2496
- fix: run hijack handlers under DisableKeepalive and MaxRequestsPerConn by @h2zi in #2494
- make PipeConns deadlines interrupt pending reads and writes by @h2zi in #2471
- fix(cookie): ignore an invalid Max-Age attribute instead of failing to parse by @nk-batman21 in #2497
- fix(fasthttpproxy): send decoded proxy credentials in Proxy-Authorization by @nk-batman21 in #2499
- fix(cookie): recognize Secure, HttpOnly and Partitioned with a value by @LuisFigueroaG in #2498
- fix(cookie): trim tabs around cookie names, values and attributes by @LuisFigueroaG in #2500
- fix(cookie): store Set-Cookie without '=' under the key ParseBytes gives it by @LuisFigueroaG in #2501
- fix(fs): send Content-Range with 416 responses by @wleeaf in #2502
New Contributors
- @ybai08 made their first contribution in #2491
- @Thanatos9404 made their first contribution in #2489
- @AdamMagued made their first contribution in #2452
- @nk-batman21 made their first contribution in #2497
- @wleeaf made their first contribution in #2502
Full Changelog: v1.76.0...v1.77.0