github valyala/fasthttp v1.81.0

52 minutes ago

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 by HijackSetNoResponse. Combined with Hijacked(), 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.Swap and ResponseHeader.Swap exchange 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/http handler supplies a nonempty Content-Encoding but no Content-Type, fasthttpadaptor skips content sniffing and suppresses fasthttp's default content type. A gzip-compressed response is therefore no longer incorrectly labeled application/x-gzip based on its compressed bytes. Both buffered and flushed responses follow this behavior. #2602

What's Changed

Security and hardening

Features

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

Don't miss a new fasthttp release

NewReleases is sending notifications on new releases.