Commit Graph

1852 Commits

Author SHA1 Message Date
Erik Dubbelboer ede09fad73 Limit FuzzTestHeaderScanner body size 2025-10-03 05:03:38 +02:00
Erik Dubbelboer 0ad54a45d9 Update lint and fix new lint errors 2025-09-28 02:59:00 +02:00
Aabishkar Aryal e7d310fd76 Add DNS cache management methods for TCPDialer (#2072)
* Add DNS cache management methods for TCPDialer

Resolves #2066

This commit introduces two new methods for managing DNS cache in TCPDialer:

1. FlushDNSCache() - Clears all cached DNS entries, forcing fresh lookups
2. CleanDNSCache() - Removes only expired entries based on DNSCacheDuration

Key changes:
- Add FlushDNSCache() and CleanDNSCache() methods to TCPDialer
- Add global FlushDNSCache() and CleanDNSCache() functions for default dialer
- Refactor tcpAddrsClean() to extract reusable cleanExpiredDNSEntries() method
- Add comprehensive tests with mock resolver to verify caching behavior

Use case: Users can now set longer cache durations (e.g., 30 minutes) and
manually refresh DNS when needed, providing better control over DNS resolution
timing while maintaining performance benefits of caching.

* Remove CleanDNSCache method to reduce the API surface layer and related tests from TCPDialer

* fix: resolve godot linter issue in client_test.go

Add missing period to comment to comply with godot linter rule requiring
comments to end with proper punctuation.
2025-09-25 14:53:57 +08:00
dependabot[bot] 563f4f66ed chore(deps): bump securego/gosec from 2.22.8 to 2.22.9 (#2073)
Bumps [securego/gosec](https://github.com/securego/gosec) from 2.22.8 to 2.22.9.
- [Release notes](https://github.com/securego/gosec/releases)
- [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml)
- [Commits](https://github.com/securego/gosec/compare/v2.22.8...v2.22.9)

---
updated-dependencies:
- dependency-name: securego/gosec
  dependency-version: 2.22.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-23 12:34:51 +08:00
Giovanni Rivera e04490f830 Add flushing support to fasthttpadaptor (#2054)
* Add flushing support to fasthttpadaptor

* refactor(fasthttphandler): Fix comment typos

* refactor(fasthttphandler): Fix early closing of net/http handler

* refactor(fasthttphandler): Apply requested changes

* refactor(fasthttphandler): Reduce memory allocations by using sync.Pool

* refactor(fasthttphandler): Fix improper releaseNetHTTPResponseWriter

* refactor(fasthttphandler): Add buffer sync.Pool with panic assert

* refactor(fasthttphandler): Fix hijacked-related response writer race condition

* refactor(fasthttphandler): Rename bufW to bufRW

* refactor(fasthttphandler): Ensure proper responseMutex use

* refactor(fasthttphandler): Specify minBufferSize to ensure reading 32 KiB chunks in streaming mode

* refactor(fasthttphandler): Fix release logic

* refactor(fasthttphandler): Fix handlerConn race condition

* refactor(fasthttphandler): Explicitly ignore handlerConn close error

* refactor(fasthttphandler): Use sync.Once, sync.Cond, and a single channel for mode management

* refactor(fasthttphandler): Remove commented code

* refactor(fasthttphandler): Add period to respect linter

* refactor(fasthttphandler): Remove return else clauses to respect lint
v1.66.0
2025-09-11 17:36:02 +02:00
Erik Dubbelboer e9640b4d39 Update benchmarks in readme
Remove benchmarks that don't work well.
2025-09-10 22:17:12 +02:00
Erik Dubbelboer 4d25421ae5 Drop Go 1.23 support (#2065)
The Go team doesn't support this version anymore. This is required to
update our golang.org/x/... dependencies.
2025-09-10 22:16:01 +02:00
Copilot 72dccd04fb Fix extra whitespace parsing in HTTP request lines to prevent cache poisoning (#2061)
* Initial plan

* Fix FastHTTP whitespace parsing issue - reject extra spaces in request lines

Co-authored-by: erikdubbelboer <522870+erikdubbelboer@users.noreply.github.com>

* Format header.go and header_test.go with gofmt

Co-authored-by: erikdubbelboer <522870+erikdubbelboer@users.noreply.github.com>

* Fix gofumpt formatting and mirror linting issues in header_test.go

Co-authored-by: erikdubbelboer <522870+erikdubbelboer@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: erikdubbelboer <522870+erikdubbelboer@users.noreply.github.com>
2025-09-09 13:42:19 -05:00
dependabot[bot] 8c7d2bc051 chore(deps): bump actions/setup-go from 5 to 6 (#2060)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5 to 6.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-05 12:56:20 +02:00
cui 28b7880b32 server: refactor to use atomic type (#2058) 2025-08-24 13:49:14 +02:00
FAUST. 68d21ed008 docs: add fasthttp-auth to related projects section (#2057) 2025-08-24 12:58:03 +02:00
dependabot[bot] 7ad0219d24 chore(deps): bump securego/gosec from 2.22.7 to 2.22.8 (#2056)
Bumps [securego/gosec](https://github.com/securego/gosec) from 2.22.7 to 2.22.8.
- [Release notes](https://github.com/securego/gosec/releases)
- [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml)
- [Commits](https://github.com/securego/gosec/compare/v2.22.7...v2.22.8)

---
updated-dependencies:
- dependency-name: securego/gosec
  dependency-version: 2.22.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-15 06:00:15 -04:00
Erik Dubbelboer f9d84d7c52 Rewrite header parsing to improve spec compliance (#2030)
This change updates header parsing to match the behavior of net/http more closely.

**Breaking change**: headers delimited by `\n` (instead of `\r\n`) are no longer supported.

Previously, fasthttp accepted `\n` as a delimiter, which is not spec compliant.
This made it difficult to correctly parse headers containing both `\n` and `\r\n`.
v1.65.0
2025-08-12 15:49:35 +02:00
dependabot[bot] 89010cb2c6 chore(deps): bump actions/checkout from 4 to 5 (#2055)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-12 15:21:57 +02:00
Erik Dubbelboer 1828bd4eee Optimize fs to have 0 allocations (#2052)
When using caching fs shouldn't cause any allocations.

Only do []byte to string conversions when really needed. When a file is
already cached the conversion shouldn't be needed.

Fixes https://github.com/valyala/fasthttp/issues/2045
2025-08-10 00:06:11 +02:00
Erik Dubbelboer 81ebee8c79 Fix PeekKeys()
RequestHeader.PeekKeys() and ResponseHeader.PeekKeys() were both
implemented wrong. The tests were also wrong causing this to never be
noticed. They both never actually returned all header keys, this has
been fixed now.

While this is a backwards incompatible change, I'm still going to
release it. Anyone using these functions would have noticed they
didn't work as documented and probably would not have continued using
them.

Fixes https://github.com/valyala/fasthttp/issues/2044
2025-08-09 13:50:07 +02:00
Erik Dubbelboer c20414a496 Remove BenchmarkCoarseTimeNow
This is not relevant anymore since CoarseTimeNow is just time.Now.
2025-08-09 13:12:17 +02:00
dependabot[bot] 3f641c3246 chore(deps): bump golang.org/x/net from 0.42.0 to 0.43.0 (#2049)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.42.0 to 0.43.0.
- [Commits](https://github.com/golang/net/compare/v0.42.0...v0.43.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.43.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-08 13:41:58 +02:00
Oleksandr Redko 51b4947320 test: replace atomic operations with atomic types (#2048) 2025-08-07 19:02:12 -04:00
jwntree 1d8fe19359 Add reuseport support for Solaris (#2046) 2025-08-04 16:27:16 +02:00
Erik Dubbelboer 01d533ad15 Fix RequestHeader.ContentLength() if disableSpecialHeader is true (#2042) 2025-07-27 08:20:03 +02:00
Erik Dubbelboer a1c842f19e Fix trailer security (#2043)
Bad trailers weren't checked correctly.

Some bad trailers that could cause security issues weren't being
disallowed.
2025-07-27 08:19:46 +02:00
dependabot[bot] dab027680c chore(deps): bump securego/gosec from 2.22.5 to 2.22.7 (#2039)
Bumps [securego/gosec](https://github.com/securego/gosec) from 2.22.5 to 2.22.7.
- [Release notes](https://github.com/securego/gosec/releases)
- [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml)
- [Commits](https://github.com/securego/gosec/compare/v2.22.5...v2.22.7)

---
updated-dependencies:
- dependency-name: securego/gosec
  dependency-version: 2.22.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-22 12:40:29 +08:00
Erik Dubbelboer ab3c358753 zstdEncoderPool was never used
releaseZstdWriter() is never called, so zstdEncoderPool is only used for Get(), never Put().

We can just inline the non Get() path of acquireZstdWriter() and remove releaseZstdWriter().

Also fixed some spelling mistakes.
2025-07-21 05:33:35 +02:00
byte0o 7e15e31a33 Simplify Client.Do function and lock usage (#2038)
* Optimization:
1. Simplify the Client.Do function, extract the acquisition of HostClient object into a separate function, and simplify the lock code
2. Remove redundant code from the AcquireReader and AcquireWriter functions of HostClient

* fix []byte to string 1 allocs/op
2025-07-19 14:37:13 +08:00
dependabot[bot] b1a54c8de5 chore(deps): bump golang.org/x/net from 0.41.0 to 0.42.0 (#2035)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.41.0 to 0.42.0.
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.42.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
v1.64.0
2025-07-11 07:32:40 +02:00
dependabot[bot] 7ac856f71f chore(deps): bump golang.org/x/crypto from 0.39.0 to 0.40.0 (#2036)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.39.0 to 0.40.0.
- [Commits](https://github.com/golang/crypto/compare/v0.39.0...v0.40.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.40.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-11 07:21:09 +02:00
dependabot[bot] 2a917b661a chore(deps): bump golang.org/x/sys from 0.33.0 to 0.34.0 (#2034)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.33.0 to 0.34.0.
- [Commits](https://github.com/golang/sys/compare/v0.33.0...v0.34.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.34.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-10 07:55:29 +02:00
Erik Dubbelboer a3c9dab757 Add warning for deprecated newline separator (#2031)
* Add warning for deprecated newline separator

* Fix feedback, no context by default, use slog
2025-07-10 06:47:32 +02:00
Kashiwa eb1f908d97 refact: eliminate duplication in Request/Response via struct embedding (#2027)
* refact: Eliminate duplication in Request/Response headers via struct embedding

* revert: SetMultipartFormBoundaryBytes

* refact: rename the params of SetProtocol and SetProtocolBytes
2025-07-05 07:51:46 +02:00
dependabot[bot] 8b512b7dae chore(deps): bump github.com/andybalholm/brotli from 1.1.1 to 1.2.0 (#2029)
Bumps [github.com/andybalholm/brotli](https://github.com/andybalholm/brotli) from 1.1.1 to 1.2.0.
- [Commits](https://github.com/andybalholm/brotli/compare/v1.1.1...v1.2.0)

---
updated-dependencies:
- dependency-name: github.com/andybalholm/brotli
  dependency-version: 1.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
v1.63.0
2025-06-24 14:02:38 +09:00
Erik Dubbelboer d356cacd84 Implement io.StringWriter on some more types (#2023)
In theory this can optimize some code paths where a string first needs
to be converted to a []byte to use the normal Write method. By
implementing WriteString this extra copy isn't needed. Internall we
don't do the copy and just use s2b instead.
2025-06-19 08:59:25 +02:00
dependabot[bot] 641dd96586 chore(deps): bump securego/gosec from 2.22.4 to 2.22.5 (#2025)
Bumps [securego/gosec](https://github.com/securego/gosec) from 2.22.4 to 2.22.5.
- [Release notes](https://github.com/securego/gosec/releases)
- [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml)
- [Commits](https://github.com/securego/gosec/compare/v2.22.4...v2.22.5)

---
updated-dependencies:
- dependency-name: securego/gosec
  dependency-version: 2.22.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-17 15:23:07 +09:00
Erik Dubbelboer 28ebbd9bf1 Drop support before go1.20 (#2022)
We still had old implementations of s2b and b2s that didn't require
unsafe.StringData and unsafe.SliceData that were added in go1.20. Since
we don't support go1.20 anymore we can drop these functions.
2025-06-15 05:14:07 +02:00
dependabot[bot] 75d2192d37 chore(deps): bump golang.org/x/net from 0.40.0 to 0.41.0 (#2018)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.40.0 to 0.41.0.
- [Commits](https://github.com/golang/net/compare/v0.40.0...v0.41.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.41.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-06 14:48:16 +09:00
Veeral Kansara 46ae933953 Proposal : To add Unsafe Zero-Allocation Conversions Sections in main documentation (#2013)
* fix: removed resolved issue link from readme file, issue no longer exists

* chore: removed wrong information from main documentation as these functions does not exist

* chore: removed old information from main documentation as these functions does not exist

* chore: added unsafe zero-allocation conversion section

---------

Co-authored-by: Veeral Kansara <veeral.kansara@brightmountainmedia.com>
2025-05-24 05:20:08 +02:00
Veeral Kansara 74f3d4cfc8 Removed old information from main documentation as these functions does not exist (#2012)
* fix: removed resolved issue link from readme file, issue no longer exists

* chore: removed wrong information from main documentation as these functions does not exist

* chore: removed old information from main documentation as these functions does not exist

---------

Co-authored-by: Veeral Kansara <veeral.kansara@brightmountainmedia.com>
2025-05-20 14:38:18 +09:00
Kashiwa a1783ffacc feat: Add iter.Seq2 iterator #2010 (#2011) 2025-05-18 13:23:04 +02:00
Erik Dubbelboer 2466344648 Remove unused file 2025-05-15 05:20:27 +02:00
Veeral Kansara d856840619 fix: removed resolved issue link from readme file, issue no longer exists (#2008)
Co-authored-by: Veeral Kansara <veeral.kansara@brightmountainmedia.com>
2025-05-10 01:57:14 +02:00
dependabot[bot] 8412015fdc chore(deps): bump securego/gosec from 2.22.3 to 2.22.4 (#2007)
Bumps [securego/gosec](https://github.com/securego/gosec) from 2.22.3 to 2.22.4.
- [Release notes](https://github.com/securego/gosec/releases)
- [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml)
- [Commits](https://github.com/securego/gosec/compare/v2.22.3...v2.22.4)

---
updated-dependencies:
- dependency-name: securego/gosec
  dependency-version: 2.22.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-09 14:24:21 +09:00
shawn wang 9e457ebd98 mod acceptConn (#2005)
* add connKeepAliveer interface{}.
* use connKeepAliveer insteadof *net.TCPConn to set TCPKeepalive and TCPKeepalivePeriod
v1.62.0
2025-05-07 14:14:06 +09:00
dependabot[bot] 69a68df4eb chore(deps): bump golang.org/x/net from 0.39.0 to 0.40.0 (#2003)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.39.0 to 0.40.0.
- [Commits](https://github.com/golang/net/compare/v0.39.0...v0.40.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.40.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-06 17:43:19 +09:00
dependabot[bot] 83fbe80f93 chore(deps): bump golang.org/x/crypto from 0.37.0 to 0.38.0 (#2002)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.37.0 to 0.38.0.
- [Commits](https://github.com/golang/crypto/compare/v0.37.0...v0.38.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-06 17:14:27 +09:00
dependabot[bot] 51817a4eb6 chore(deps): bump golangci/golangci-lint-action from 7 to 8 (#2001)
* chore(deps): bump golangci/golangci-lint-action from 7 to 8

Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 7 to 8.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v7...v8)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update lint version

* disable funcorder

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2025-05-05 15:50:24 +09:00
Max Denushev 41a1449627 feat: move user values to Request structure (#1999)
Co-authored-by: Max Denushev <denushev@tochka.com>
2025-05-03 15:10:15 +09:00
osxtest 1345f42ede Add support for streaming identity-encoded or unknown length response bodies (#2000) 2025-05-03 13:51:32 +09:00
pj a05560dd7e implement early hints (#1996) v1.61.0 2025-04-21 13:01:35 +02:00
Erik Dubbelboer 48f3a2f423 Fix panic when perIPConn.Close is called multiple times (#1993)
This happens when a perIPConn is idle and closed during
Server.Shutdown() and then again closed by the WorkerFunc returning.
2025-04-12 04:36:07 +02:00
Yota Toyama e380d34bce Fix round robin addresses in dual stack dialing (#1995) 2025-04-11 15:00:19 +09:00