aboutsummaryrefslogtreecommitdiff
path: root/fs.go
AgeCommit message (Collapse)AuthorFilesLines
2024-04-29Implemented what was described by me in #1766. (#1767)Gravatar Limux 1-0/+6
* Implemented what was described by me in issue#1766. * fixed linting isssues in fs.go with gofmt -e -d -s --------- Co-authored-by: Raphael Habichler <raphael.habichler@bmd.at>
2024-03-25refactor: rename error local variables (#1738)Gravatar Oleksandr Redko 1-12/+12
2024-03-02Enable few gocritic checks; fix up issues (#1728)Gravatar Oleksandr Redko 1-2/+2
2024-02-21feat:support zstd compress and uncompressed (#1701)Gravatar Co1a 1-15/+59
* feat:support zstd compress and uncompressed * fix:real & stackless write using different pool to avoid get stackless.writer * fix:zstd normalize compress level * Change empty string checks to be more idiomatic (#1684) * chore:lint fix and rebase with master * chore:remove 1.18 test & upgrade compress version * fix:error default compress level * Fix lint --------- Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2024-02-21Upgrade golangci-lint to v1.56.2; fix gocritic issues (#1722)Gravatar Oleksandr Redko 1-3/+3
2024-01-04Change empty string checks to be more idiomatic (#1684)Gravatar Oleksandr Redko 1-6/+6
2023-12-13chore: Add missing dots at the end of comments (#1677)Gravatar Oleksandr Redko 1-2/+2
2023-12-05chore: Set max line length to 130 characters (#1676)Gravatar Oleksandr Redko 1-2/+6
2023-11-12Enable dupword, unconvert linters (#1658)v1.51.0Gravatar Oleksandr Redko 1-2/+2
2023-11-05Skip fs cache based on config (#1644)Gravatar Tiago Peczenyj 1-94/+193
* add cache manager struce * refactor cache by adding interface * generalize ctor * implement feature add unit tests * fix code * rename fs field as filesystem
2023-11-05Add support to fs.fs on serve static files (#1640)Gravatar Tiago Peczenyj 1-44/+194
* substitute *os.File by fs.File * refactor error handling by using the new recommended form * finish implementation * substitute seek(offset,0) by seek(offset, io.SeekStart) * add unit test * use io.SeekStart on Seek method
2023-05-24fs: fix race condition on global map (#1565)Gravatar leonklingele 1-1/+5
* fs: fix race condition on global map Previously, when creating multiple FS instances with a non-empty "CompressedFileSuffix" field concurrently, a data race on the global "FSCompressedFileSuffixes" might occur. This was found in fiber, probably the largest web framework based on fasthttp: git clone https://github.com/gofiber/fiber.git && cd fiber git checkout 182f9f09705eab40c61a618835d46faee79c1e49 go test -v -race -run Test_App_Static_Prefix_* === RUN Test_App_Static_Prefix_Wildcard === PAUSE Test_App_Static_Prefix_Wildcard === RUN Test_App_Static_Prefix === PAUSE Test_App_Static_Prefix === CONT Test_App_Static_Prefix === CONT Test_App_Static_Prefix_Wildcard ================== WARNING: DATA RACE Write at 0x00c0001b1c50 by goroutine 7: runtime.mapassign_faststr() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/runtime/map_faststr.go:203 +0x0 github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:434 +0x2c4 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x84 github.com/gofiber/fiber/v2.Test_App_Static_Prefix_Wildcard() /home/leon/code/fiber/app_test.go:1017 +0x5c testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Previous write at 0x00c0001b1c50 by goroutine 8: runtime.mapassign_faststr() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/runtime/map_faststr.go:203 +0x0 github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:434 +0x2c4 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x84 github.com/gofiber/fiber/v2.Test_App_Static_Prefix() /home/leon/code/fiber/app_test.go:1042 +0x59 testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Goroutine 7 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 Goroutine 8 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 ================== ================== WARNING: DATA RACE Write at 0x00c0001f43e8 by goroutine 7: github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:434 +0x2d3 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x84 github.com/gofiber/fiber/v2.Test_App_Static_Prefix_Wildcard() /home/leon/code/fiber/app_test.go:1017 +0x5c testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Previous write at 0x00c0001f43e8 by goroutine 8: github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:434 +0x2d3 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x84 github.com/gofiber/fiber/v2.Test_App_Static_Prefix() /home/leon/code/fiber/app_test.go:1042 +0x59 testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Goroutine 7 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 Goroutine 8 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 ================== ================== WARNING: DATA RACE Read at 0x00c0001f43f8 by goroutine 7: github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:435 +0x344 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x84 github.com/gofiber/fiber/v2.Test_App_Static_Prefix_Wildcard() /home/leon/code/fiber/app_test.go:1017 +0x5c testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Previous write at 0x00c0001f43f8 by goroutine 8: github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:435 +0x38c github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x84 github.com/gofiber/fiber/v2.Test_App_Static_Prefix() /home/leon/code/fiber/app_test.go:1042 +0x59 testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Goroutine 7 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 Goroutine 8 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 ================== ================== WARNING: DATA RACE Read at 0x00c0001b1c50 by goroutine 11: runtime.mapaccess1_faststr() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/runtime/map_faststr.go:13 +0x0 github.com/valyala/fasthttp.(*fsHandler).newFSFile() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:1329 +0xec github.com/valyala/fasthttp.(*fsHandler).openFSFile() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:1317 +0x7c9 github.com/valyala/fasthttp.(*fsHandler).handleRequest() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:865 +0x846 github.com/valyala/fasthttp.(*fsHandler).handleRequest-fm() <autogenerated>:1 +0x44 github.com/gofiber/fiber/v2.(*App).registerStatic.func3() /home/leon/code/fiber/router.go:403 +0x15e github.com/gofiber/fiber/v2.(*App).next() /home/leon/code/fiber/router.go:144 +0x50b github.com/gofiber/fiber/v2.(*App).handler() /home/leon/code/fiber/router.go:171 +0xf2 github.com/gofiber/fiber/v2.(*App).handler-fm() <autogenerated>:1 +0x44 github.com/valyala/fasthttp.(*Server).serveConn() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/server.go:2365 +0x1b4a github.com/valyala/fasthttp.(*Server).ServeConn() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/server.go:2035 +0x10f github.com/gofiber/fiber/v2.(*App).Test.func1() /home/leon/code/fiber/app.go:934 +0xd8 Previous write at 0x00c0001b1c50 by goroutine 7: runtime.mapassign_faststr() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/runtime/map_faststr.go:203 +0x0 github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:435 +0x37d github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x84 github.com/gofiber/fiber/v2.Test_App_Static_Prefix_Wildcard() /home/leon/code/fiber/app_test.go:1017 +0x5c testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Goroutine 11 (running) created at: github.com/gofiber/fiber/v2.(*App).Test() /home/leon/code/fiber/app.go:926 +0x645 github.com/gofiber/fiber/v2.Test_App_Static_Prefix() /home/leon/code/fiber/app_test.go:1045 +0xba testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Goroutine 7 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 ================== ================== WARNING: DATA RACE Write at 0x00c0001b1c50 by goroutine 8: runtime.mapassign_faststr() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/runtime/map_faststr.go:203 +0x0 github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:434 +0x2c4 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x2c6 github.com/gofiber/fiber/v2.Test_App_Static_Prefix() /home/leon/code/fiber/app_test.go:1051 +0x29b testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Previous write at 0x00c0001b1c50 by goroutine 7: runtime.mapassign_faststr() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/runtime/map_faststr.go:203 +0x0 github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:434 +0x2c4 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x2c9 github.com/gofiber/fiber/v2.Test_App_Static_Prefix_Wildcard() /home/leon/code/fiber/app_test.go:1026 +0x29b testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Goroutine 8 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 Goroutine 7 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 ================== ================== WARNING: DATA RACE Write at 0x00c0001f43e8 by goroutine 8: github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:434 +0x2d3 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x2c6 github.com/gofiber/fiber/v2.Test_App_Static_Prefix() /home/leon/code/fiber/app_test.go:1051 +0x29b testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Previous write at 0x00c0001f43e8 by goroutine 7: github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:434 +0x2d3 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x2c9 github.com/gofiber/fiber/v2.Test_App_Static_Prefix_Wildcard() /home/leon/code/fiber/app_test.go:1026 +0x29b testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Goroutine 8 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 Goroutine 7 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 ================== ================== WARNING: DATA RACE Read at 0x00c0001f43f8 by goroutine 8: github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:435 +0x344 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x2c6 github.com/gofiber/fiber/v2.Test_App_Static_Prefix() /home/leon/code/fiber/app_test.go:1051 +0x29b testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Previous write at 0x00c0001f43f8 by goroutine 7: github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:435 +0x38c github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x2c9 github.com/gofiber/fiber/v2.Test_App_Static_Prefix_Wildcard() /home/leon/code/fiber/app_test.go:1026 +0x29b testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Goroutine 8 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 Goroutine 7 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 ================== ================== WARNING: DATA RACE Write at 0x00c0001b1c50 by goroutine 8: runtime.mapassign_faststr() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/runtime/map_faststr.go:203 +0x0 github.com/valyala/fasthttp.(*FS).initRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:434 +0x2c4 github.com/valyala/fasthttp.(*FS).initRequestHandler-fm() <autogenerated>:1 +0x39 sync.(*Once).doSlow() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:74 +0x101 sync.(*Once).Do() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/sync/once.go:65 +0x46 github.com/valyala/fasthttp.(*FS).NewRequestHandler() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:389 +0x9bb github.com/gofiber/fiber/v2.(*App).registerStatic() /home/leon/code/fiber/router.go:396 +0x984 github.com/gofiber/fiber/v2.(*App).Static() /home/leon/code/fiber/app.go:762 +0x4f0 github.com/gofiber/fiber/v2.Test_App_Static_Prefix() /home/leon/code/fiber/app_test.go:1060 +0x4c5 testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 Previous read at 0x00c0001b1c50 by goroutine 20: runtime.mapaccess1_faststr() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/runtime/map_faststr.go:13 +0x0 github.com/valyala/fasthttp.(*fsHandler).newFSFile() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:1329 +0xec github.com/valyala/fasthttp.(*fsHandler).openFSFile() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:1317 +0x7c9 github.com/valyala/fasthttp.(*fsHandler).handleRequest() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/fs.go:865 +0x846 github.com/valyala/fasthttp.(*fsHandler).handleRequest-fm() <autogenerated>:1 +0x44 github.com/gofiber/fiber/v2.(*App).registerStatic.func3() /home/leon/code/fiber/router.go:403 +0x15e github.com/gofiber/fiber/v2.(*App).next() /home/leon/code/fiber/router.go:144 +0x50b github.com/gofiber/fiber/v2.(*App).handler() /home/leon/code/fiber/router.go:171 +0xf2 github.com/gofiber/fiber/v2.(*App).handler-fm() <autogenerated>:1 +0x44 github.com/valyala/fasthttp.(*Server).serveConn() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/server.go:2365 +0x1b4a github.com/valyala/fasthttp.(*Server).ServeConn() /home/leon/go/pkg/mod/github.com/valyala/fasthttp@v1.47.0/server.go:2035 +0x10f github.com/gofiber/fiber/v2.(*App).Test.func1() /home/leon/code/fiber/app.go:934 +0xd8 Goroutine 8 (running) created at: testing.(*T).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x805 testing.runTests.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2036 +0x8d testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.runTests() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:2034 +0x87c testing.(*M).Run() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1906 +0xb44 main.main() _testmain.go:871 +0x2e9 Goroutine 20 (finished) created at: github.com/gofiber/fiber/v2.(*App).Test() /home/leon/code/fiber/app.go:926 +0x645 github.com/gofiber/fiber/v2.Test_App_Static_Prefix_Wildcard() /home/leon/code/fiber/app_test.go:1028 +0x304 testing.tRunner() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1576 +0x216 testing.(*T).Run.func1() /nix/store/8v5zwymidmry0wd3lhj6zggskzsvqrfk-go-1.20.4/share/go/src/testing/testing.go:1629 +0x47 ================== testing.go:1446: race detected during execution of test --- FAIL: Test_App_Static_Prefix_Wildcard (0.03s) === NAME Test_App_Static_Prefix testing.go:1446: race detected during execution of test --- FAIL: Test_App_Static_Prefix (0.03s) FAIL exit status 1 FAIL github.com/gofiber/fiber/v2 0.050s * Update fs.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> --------- Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2023-03-30get rid of some panics (#1526)Gravatar Moritz Poldrack 1-1/+2
* client: simplify (*HostClient).do() Remove an allocation in favour of deferring a call to release the response. * client: remove panic in dialAddr Return an error instead of panicking if the user supplied a nonsensical DialFunc. * compression: remove panic on invalid compression level If a compression level exceeding gzip's boundaries is provided, fasthttp will panic. Instead it would be better to handle this error for them by limiting it to the minimum or maximum value, depending on the direction the user has exceeded the limits. Clamp the value of gzip to always be between gzip.BestSpeed and gzip.BestCompression. * peripconn: remove panic on negative connection count When a negative count is reached when unregistering a connection, a panic is caused even though data-integrity is not at risk. Replace the panic() with a simple clamp on the value to ensure the value does not exceed it's expected lower bounds. References: #1504 * compress: remove error on failed nonblocking writes Since there is no way of handling or even logging non-critical errors in stateless non-blocking writecalls, just drop them and hope the user notices and tries again. * workerPool: remove panic on redundant Start and Stop calls Instead of panicking for invalid behaviour, it's preferable to just turn the function into a noop. * http: remove panic on invalid form boundary * http: remove panic on negative reads Since bufio already panics on negative reads, it is not necessary to do so as well. If the length is zero and for some reason no error is returned, readBodyIdentity and appendBodyFixedSize now errors in these cases. Link: https://github.com/golang/go/blob/851f6fd61425c810959c7ab51e6dc86f8a63c970/src/bufio/bufio.go#L246 * fs: remove panic on negative reader count When a negative count is reached when unregistering a reader, a panic is thrown even though data-integrity is not at risk. Replace the panic() with a simple clamp on the value to ensure the value does not exceed it's expected lower bounds. * server: remove panic in favour of a segfault Panicking with "BUG: " obscures the error. As the segfault causes a panic anyway, just let the chaos unfold. * server: remove panic in favour of returning an error Writing on a timed-out response is not endangering data integrity and just fails. * chore: add comments to all panics * chore: fix minor typo
2023-02-13docs: fix grammar issues and typos in comments (#1492)Gravatar Oleksandr Redko 1-1/+1
2023-02-11Refactor golangci-lint config and remove redundant nolints (#1486)Gravatar Oleksandr Redko 1-1/+1
* Refactor golangci-lint config - Use golangci-lint-action for GitHub workflow. - Add additional golangci-lint run options. - Remove unused nolint directives. * Revert exclude-use-default option
2022-11-28Revert "feat: support mulit/range (#1398)" (#1446)v1.43.0Gravatar Erik Dubbelboer 1-665/+122
This reverts commit a468a7dd3734d9866ef6ab8ee1e36695f5c3b09c.
2022-10-30feat: support mulit/range (#1398)Gravatar byene0923 1-122/+665
* feat: support mulit/range * fix: 1. lint code 2. add SetByteRanges method * fix: reduce the test number of testFSSingleByteRange
2022-09-15Deprecate Go 1.15 (#1379)Gravatar Aoang 1-2/+1
* Dropping support for 1.15. * Replaces Go 1.16 Deprecated functions * Update test build flag * Fix import sort and comment * Update github.com/klauspost/compress to v1.15.9 https://github.com/klauspost/compress improved performance and changed Minimum version is 1.16, this should be the final supported release for Go 1.16 (https://github.com/klauspost/compress/commit/6d0019a95afa3221f7522d1f2eed0033b5e79470) .
2022-08-14Add Go 1.19 Support (#1355)v1.39.0Gravatar Aoang 1-16/+15
* Update Go Version to Go1.19.x And add cache * Fix CI Line endings * Update test CI Go Version to Go1.19.x And add cache * Update Gosec Security Scanner CI to securego/gosec@v2.12.0 * Format comment Go 1.19 adds support for links, lists, and clearer headings in doc comments. As part of this change, gofmt now reformats doc comments to make their rendered meaning clearer. See “Go Doc Comments” for syntax details and descriptions of common mistakes now highlighted by gofmt. As another part of this change, the new package go/doc/comment provides parsing and reformatting of doc comments as well as support for rendering them to HTML, Markdown, and text. ref: https://tip.golang.org/doc/go1.19 ref: https://tip.golang.org/doc/comment * Fix doc structure
2022-07-10Introduce FS.CompressRoot (#1331)Gravatar mojatter 1-5/+42
* Introduce FS.CompressRoot * Avoid duplicated filepath.FromSlash * Introduce filePathToCompressed * Revert openIndexFile manually * Join root and path, and then calls filepath.FromSlash
2022-06-05Response.ContentEncoding(): store as field and avoid using ↵Gravatar Sergey Ponomarev 1-4/+4
Header.SetCanonical() (#1311) * Response.ContentEncoding(): store as field The CE is not so often used for plain APIs responses and even not so often used for static files and on the fly compression. But still it should be checked each time. Also having a dedicated field getter and setter simplifies code * header.go Use shorter Response.setNonSpecial() and Request.setNonSpecial() methods instead of SetCanonical() The change should improve performance because the setSpecialHeader() call is omitted. As a downside on adding a new basic header field all putHeader() must be replaced with a direct getter and setter.
2022-05-16Add an option to allow empty root in the fsHandler (#1299)v1.37.0Gravatar RW 1-11/+15
* Add an option to allow empty root in the fsHandler this is necessary to restore the capabilities before the commit https://github.com/valyala/fasthttp/commit/c7576cc10cabfc9c993317a2d3f8355497bea156 and to allow further functionality to be docked from the outside which is not affected by setting the root dir afterwards https://github.com/gofiber/fiber/pull/1882#issuecomment-1120832500 * Add an option to allow empty root in the fsHandler this is necessary to restore the capabilities before the commit https://github.com/valyala/fasthttp/commit/c7576cc10cabfc9c993317a2d3f8355497bea156 and to allow further functionality to be docked from the outside which is not affected by setting the root dir afterwards https://github.com/gofiber/fiber/pull/1882#issuecomment-1120832500 * Update fs.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> * Update fs.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2022-04-09Added Windows support and removed some panics (#1264)Gravatar Mauro Leggieri 1-49/+68
2022-04-01Use %v for errors and %q for strings (#1262)v1.35.0Gravatar Erik Dubbelboer 1-9/+9
Mostly in tests.
2022-03-03Warn about unsafe ServeFile usage (#1228)Gravatar Erik Dubbelboer 1-0/+16
See: https://github.com/valyala/fasthttp/issues/1226
2021-12-13Use %w to wrap errors (#1175)Gravatar Erik Dubbelboer 1-11/+11
2021-11-04Fix lintGravatar Erik Dubbelboer 1-2/+2
2021-11-04use sync.map is better (#1145)Gravatar halst 1-12/+4
* use sync.map is better * Use LoadOrStore
2021-02-06Allow stopping FS handler cleanup gorountine (#942)Gravatar Erik Dubbelboer 1-1/+26
* Allow stopping FS handler cleanup gorountine * CleanStop
2020-09-28Brotli support in FS handler. (#880)Gravatar hex0x00 1-73/+150
* Add files via upload * Update fs.go * Add files via upload * Update fs_test.go
2020-06-12Fixed bug which prevents cached FS files from being updatedGravatar Erik Dubbelboer 1-1/+1
Bug was introduced in previous "Fixed recompressing of stale files" commit.
2020-06-07Fixed recompressing of stale filesGravatar Erik Dubbelboer 1-1/+4
2020-06-04🐞 panic in fs.go #824 (#825)Gravatar RW 1-2/+2
Co-authored-by: wernerr <rene.werner@verivox.com>
2020-05-18Make FS return a redirect for directories without trailing slash (#802)Gravatar Moritz Marquardt 1-0/+9
* Make FS return a redirect for directories without trailing slash Fixes #792 * Add a test for the directory redirect * Fix directory redirects for ServeFile * Fix error message Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2019-11-16Run golangci-lint using a Github ActionGravatar Erik Dubbelboer 1-2/+4
2019-02-02Various changes regarding code readibility (#523)Gravatar Shulhan 1-1/+1
* all: use sort.Strings when applicable Basically, sort.Strings is the shortcut of Sort(StringSlice(a)) but its more readable. * all: replace string(bytes.Buffer.Bytes()) with bytes.Buffer.String() Although its only occured on test files, it may be worth to simplified it. * http_test: simplify strings.Index with strings.Contains Both have the same O(n), but strings.Contains more readable on if-condition. * args: simplify if-condition check on boolean value * all: simplify variable initialization If we assign the variable after declaring it, we can simplify it using ":=" operator or "= value". The reader can still known the type of variable from the struct name or variable type before assignment operator.
2019-01-30all: pre-allocated slice with possible known sizeGravatar Shulhan 1-1/+1
This fix is based on suggestion of "prealloc" static analysis tool [1]. Per note of the tool's author suggestion, its recommended to allocate the slice length/capability, if we known their possible size. This is to minimize "append" to re-allocate the slice underlying array. [1] https://github.com/alexkohler/prealloc
2018-10-01Remove fasthttp.ByteBufferGravatar Erik Dubbelboer 1-4/+5
As advertised in https://github.com/valyala/fasthttp/commit/b5f96d4b4120bb1e09c23ac32baf21a14da4a71d
2018-09-20Fix Content-Type bug in FSGravatar Erik Dubbelboer 1-1/+2
Fixes #417
2018-09-13Allow overwrite of ContentType by caller of RequestCtx.ServeFileGravatar Jerry Jacobs 1-1/+3
2018-08-17fs/pathNotFound: do not overwrite user's status codeGravatar Kirill Danshin 1-1/+1
Signed-off-by: Kirill Danshin <k@guava.by>
2018-08-17Added PathNotFound handle func for handling 404.Gravatar Erik Dubbelboer 1-1/+16
See https://github.com/erikdubbelboer/fasthttp/pull/10
2017-10-08A lot of typo fixesGravatar xPushkin 1-1/+1
2017-05-17Limit heap memory usage when compressing high number of concurrent responsesGravatar Aliaksandr Valialkin 1-8/+3
Previously each concurrent compression could allocate huge compression state with the size up to 1Mb each. So 10K concurrent connections could result in 10Gb of compression state in the heap. This CL limits the number of compression states among concurrent requests when {Append,Write}{Gzip,Deflate}* functions are called to O(GOMAXPROCS). These functions are used by CompressHandler* for non-streaming responses, i.e. it should cover the majority of use cases. Memory usage for 10K concurrent connections that compress responses drops from 10Gb to 200Mb after this CL.
2016-10-20Revert "Use standard compress packages until ↵Gravatar Aliaksandr Valialkin 1-1/+2
https://github.com/klauspost/compress/issues/64 is fixed" The original issue has been fixed, so reverting. This reverts commit 2f4876aaf2b591786efc9b49f34b86ad44c25074.
2016-10-20Use standard compress packages until ↵Gravatar Aliaksandr Valialkin 1-2/+1
https://github.com/klauspost/compress/issues/64 is fixed
2016-10-13Revert "Use standard compress/* packages instead of ↵Gravatar Aliaksandr Valialkin 1-1/+2
github.com/klauspost/compress/*" According to @klauspost, his packages are still faster than the standard packages. See https://github.com/valyala/fasthttp/commit/a98191f43560ea2ddbbf848c1c727daeed2e39ae#commitcomment-19409416 for details. This reverts commit a98191f43560ea2ddbbf848c1c727daeed2e39ae.
2016-10-13Use standard compress/* packages instead of github.com/klauspost/compress/*Gravatar Aliaksandr Valialkin 1-2/+1
The reasons are: - @klauspost optimized standard packages in go1.7+ - This removes an external dependency from fasthttp
2016-07-12Add test for fsSmallFileReader.WriteTo and fix bug (#128)Gravatar Victor Gaydov 1-1/+1
The bug raises when io.Writer passed to fsSmallFileReader.WriteTo doesn't support ReadFrom interface.
2016-05-24Issue #103: Added FS.CompressedFileSuffix and clarified ↵Gravatar Aliaksandr Valialkin 1-29/+43
FSHandlerCacheDuration documentation