* ♻️ Refactor: Extract testConn err to variable
* ♻️ Refactor: Extract ErrTestGotEmptyResponse from app.Test()
* 🩹 Fix: Fix `app.Test()` auto-failing when testConn is closed
* 🩹 Fix(app_test.go): Use tab for indent instead of spaces
* 🩹 Fix(app_test.go): Fix to respect gofmt linter
* ♻️ Refactor: Update Drop tests to verify error type
* 🔥 Feature: Add thread-safe reading from a closed testConn
* 🔥 Feature: Add TestConfig to app.Test()
This commit is summarized as:
- Add the struct `TestConfig` as a parameter for `app.Test()` instead of `timeout`
- Add documentation of `TestConfig` to docs/api/app.md and in-line
- Modify middleware to use `TestConfig` instead of the previous implementation
Fixes#3149
* 📚 Doc: Add more details about TestConfig in docs
* 🩹 Fix: Correct testConn tests
- Fixes Test_Utils_TestConn_Closed_Write
- Fixes missing regular write test
* 🎨 Style: Respect linter in Add App Test Config
* 🎨 Styles: Update app.go to respect linter
* ♻️ Refactor: Rename TestConfig's ErrOnTimeout to FailOnTimeout
- Rename TestConfig.ErrOnTimeout to TestConfig.FailOnTimeout
- Update documentation to use changed name
- Also fix stale documentation about passing Timeout as a
single argument
* 🩹 Fix: Fix typo in TestConfig struct comment in app.go
* ♻️ Refactor: Change app.Test() fail on timeouterror to os.ErrDeadlineExceeded
* ♻️ Refactor:Update middleware that use the same TestConfig to use a global variable
* 🩹 Fix: Update error from FailOnTimeout to os.ErrDeadlineExceeded in tests
* 🩹 Fix: Remove errors import from middlware/proxy/proxy_test.go
* 📚 Doc: Add `app.Test()` config changes to docs/whats_new.md
* ♻ Refactor: Change app.Test() and all uses to accept 0 as no timeout instead of -1
* 📚 Doc: Add TestConfig option details to docs/whats_new.md
* 🎨 Styles: Update docs/whats_new.md to respect markdown-lint
* 🎨 Styles: Update docs/whats_new.md to use consistent style for TestConfig options description
---------
Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
* Use composites for internal structures. Fix alignment of structures across Fiber
* Update struct alignment in test files
* Enable alignment check with govet
* Fix ctx autoformat unit-test
* Revert app Config struct. Add betteralign to Makefile
* Disable comment on alert since it wont work for forks
* Update benchmark.yml
* Update benchmark.yml
* Remove warning from using positional fields
* Update router.go
* Fixes for some of the failing tests
* Add readiness check to serverStart()
* Use net/http client for tests listen test
* Use different key for this test
* Run Proxy Middleware tests in parallel. Add nil checks for potential issues pointed by nilaway
* Enable parallel client tests
* Do not run timing sensitive tests in parallel
* Remove TODO
* Revert Test_Proxy_DoTimeout_Timeout, and remove t.Parallel() for it
* Do not calculate favicon len on each handler call
* Revert logic change
* Increase timeout of SaveFile tests
* Do not run time sensitive tests in parallel
* The Agent can't be run in parallel
* Do not run time sensitive tests in parallel
* Fixes based on uber/nilaway
* Revert change to Client test
* Run parallel
* Update client_test.go
* Update client_test.go
* Update cache_test.go
* Update cookiejar_test.go
* Remove parallel for test using timeouts
* Remove t.Parallel() from logger middleware tests
* Do not use testify.require in a goroutine
* Fix import, and update golangci-lint
* Remove changes to template_chain.go
* Run more tests in parallel
* Add more parallel tests
* Add more parallel tests
* SetLogger can't run in parallel
* Run more tests in parallel, fix issue with goroutine in limiter middleware
* Update internal/storage/memory, add more benchmarks
* Increase sleep for csrf test by 100 milliseconds. Implement asserted and parallel benchmarks for Session middleware
* Add 100 milliseconds to sleep during test
* Revert name change
* fix: Inconsistent and flaky unit-tests
* fix: Inconsistent and flaky unit-tests
* fix: Inconsistent and flaky unit-tests
* fix: Inconsistent and flaky unit-tests
* fix: Inconsistent and flaky unit-tests
* fix: Inconsistent and flaky unit-tests
* fix: Inconsistent and flaky unit-tests
* fix: Inconsistent and flaky unit-tests
* fix: Inconsistent and flaky unit-tests
* fix: Inconsistent and flaky unit-tests
---------
Co-authored-by: M. Efe Çetin <efectn@protonmail.com>
Co-authored-by: René <rene@gofiber.io>
* refactor: Update to use fasthttp.VisitHeaderParams
The implementation of forEachParameter was upstreamed to fasthttp, so
use that version instead of maintaining our own.
* refactor: use map for header params
The previous implementation of content negotiation used some difficult
to understand techniques in order to reduce allocations, potentially
hurting maintainability. The more natural approach for storing and
comparing unordered media-type parameters is to utilize maps. While the
resulting code still isn't as simple as it could be, it's a step closer.
To reduce allocations, we use a sync.Pool. This actually reduces in fewer
allocations than before at 3 or more parameters. The net result is nearly
identical performance for zero parameters, almost-as-good performance for
1-2 parameters, and better performance for 3+ parameters.
---------
Co-authored-by: Jason McNeil <sixcolors@mac.com>
* Update linter.yml
* Disable spancheck, fix some of the errors
* Fix ErrorAs, disable go-require from testifylint
* Remove extra space
* Fix all warnings from golangci-lint and revive unused params
* Refactor CopyContextToFiberContext
* Update adaptor.go
* ✨ feat: add support for parameters in content negotiation
Attempts to approach the level of support offered by express,
but behavior may differ in unusual corner cases.
Some key behaviors from Express that are implemented:
- If an offer does not have every parameter listed in the given Accept,
it is rejected.
- Parameters do not affect specificity.
- In a given specificity, more parameters gives greater precedence
- Parameters are unordered
- Matching is case-insensitive
- Surrounding quotes for parameter values are stripped
- If an Accept type specifies a parameter more than once, the last
value provided is taken.
- Parameters after q are not processed.
https://www.rfc-editor.org/rfc/rfc9110#name-parameters
* doc: properly attribute reader.go for validHeaderFieldByte
* fix: remove underscores from fuzz test name
* test(forEachParameter): improve coverage
* doc: add comment clarifying RFC 9110 non-compliance for corner case
* 🔧 feat: Decode body in order when sent a list on content-encoding
* 🚀 perf: Change `getSplicedStrList` to have 0 allocations
* 🍵 test: Add tests for the new features
* 🍵 test: Ensure session test will not raise an error unexpectedly
* 🐗 feat: Replace strings.TrimLeft by utils.TrimLeft
Add docs to functions to inform correctly what the change is
* 🌷 refactor: Apply linter rules
* 🍵 test: Add test cases to the new body method change
* 🔧 feat: Remove return problems to be able to reach original body
* 🌷 refactor: Split Body method into two to make it more maintainable
Also, with the previous fix to problems detected by tests, it becomes really hard to make the linter happy, so this change also helps in it
* 🚀 perf: Came back with Header.VisitAll, to improve speed
* 📃 docs: Update Context docs
* golangci-lint: add and apply more stricter linting rules
* github: drop security workflow now that we use gosec linter inside golangci-lint
* github: use official golangci-lint CI linter
* Add editorconfig and gitattributes file
* fix unhandled errors
* fix unhandled error in cache package test
* omit variable type
* omit variable type
* rename variable because collide with the imported package name
* handle file error on closing
* fix unhandled in common_linux.go
* fix unhandled errors in helpers_test.go