v1.81.0 tightens request-header termination, fixes content-type handling for encoded responses in fasthttpadaptor, and adds APIs for inspecting hijack behavior and exchanging headers without copying their contents.
Security fixes and hardening
- Nonempty request header blocks must end with CRLFCRLF. The parser validates the terminator at the first blank line instead of allowing a later CRLFCRLF sequence to make a malformed boundary appear valid. This keeps request boundaries consistent across fragmented reads and pipelined requests. Bare LF line endings within the block remain accepted when the block itself ends correctly. #2610
Features
- Middleware can inspect whether hijacking suppresses the response.
RequestCtx.HijackNoResponse()returns the setting established byHijackSetNoResponse. Combined withHijacked(), it lets middleware distinguish a connection takeover without an HTTP response from one where fasthttp writes the response first. The setting only takes effect when hijacking is requested; existing hijack behavior is unchanged. #2614 - Headers can be exchanged without copying their contents.
RequestHeader.SwapandResponseHeader.Swapexchange contents, buffers, and settings, including cookies, trailers, and header normalization. Previously obtained byte slices continue to reference the same buffers, which belong to the other header after the swap. This avoids copying header data when moving it between requests or responses. #2615
HTTP compatibility
- Adapted handlers no longer infer a content type from encoded bytes. When a
net/httphandler supplies a nonemptyContent-Encodingbut noContent-Type,fasthttpadaptorskips content sniffing and suppresses fasthttp's default content type. A gzip-compressed response is therefore no longer incorrectly labeledapplication/x-gzipbased on its compressed bytes. Both buffered and flushed responses follow this behavior. #2602
What's Changed
Security and hardening
- Require CRLFCRLF at the end of nonempty request header blocks by @erikdubbelboer in #2610
Features
- feat: add RequestCtx.HijackNoResponse by @ReneWerner87 in #2614
- feat: add Swap to exchange two headers without copying by @ReneWerner87 in #2615
Fixes
- fix(fasthttpadaptor): do not sniff the Content-Type of an encoded body by @ruziba3vich in #2602
Dependency updates
- chore(deps): bump golang.org/x/net from 0.62.0 to 0.63.0 by @dependabot[bot] in #2609
- chore(deps): bump github.com/klauspost/compress from 1.20.4 to 1.20.5 by @dependabot[bot] in #2608
Full Changelog: v1.80.0...v1.81.0