Commit Graph

1586 Commits

Author SHA1 Message Date
Anthony Ter-Saakov b79233fac2 add DisableSpecialHeaders option (#1573)
* add DisableSpecialHeaders option

* polishing up disableSpecialHeader option

* forgot to uncomment

* fix silly mistakes

* dont parse special headers
2023-06-12 21:49:52 +02:00
leonklingele f0865d4aab fs: fix race condition on global map (#1565)
* 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-05-24 12:29:42 +02:00
Erik Dubbelboer 829f5b2445 Don't run test that times out often in parallel 2023-05-23 10:14:50 +02:00
Erik Dubbelboer e6ce5f0b11 Remove invalid documentation
The Timeout functions don't use separate goroutines anymore and use
normaly deadlines. Because of that requests are terminated and don't
keep running in the background as before.
2023-05-22 16:27:56 +02:00
byte0o 9bc8e480c4 Request timeout settings for the same domain name are reused (#1558)
* Update client.go

fix client http SetReadDeadline/SetWriteDeadline Deadline is reused

* delete Deadline comments  fix test singleEchoConn implement SetWriteDeadline/SetReadDeadline

* fix test SetReadDeadline/SetWriteDeadline none implement

---------

Co-authored-by: gaoping <gaoping1@wps.cn>
2023-05-14 12:55:02 +02:00
Zhengkai Wang d2f97fc426 fix the problem: HostClient maybe delete when pendingClientRequests > 0 (#1562)
* add the functions to get host clients

* add concurrency for client's HostClient map

* delete test code

* add lock in once block

* fix the problem: HostClient maybe delete when pendingClientRequests > 0

* fix the problem: HostClient maybe delete when pendingClientRequests > 0

---------

Co-authored-by: wangzhengkai.wzk <wangzhengkai.wzk@alibaba-inc.com>
2023-05-12 09:49:37 +02:00
Zhengkai Wang 7ea3b6330e add concurrency for client's HostClient map (#1550)
* add the functions to get host clients

* add concurrency for client's HostClient map

* delete test code

* add lock in once block

---------

Co-authored-by: wangzhengkai.wzk <wangzhengkai.wzk@alibaba-inc.com>
2023-05-11 10:07:58 +02:00
Oleksandr Redko eaab8ffc39 Refactor by removing unnecessary else block (#1559) 2023-05-11 10:01:44 +02:00
tyltr 1a46e573a1 update go.sum (#1555) 2023-05-11 09:56:53 +02:00
Erik Dubbelboer fa72f3cc39 Fix tests (#1552) 2023-05-07 14:32:14 +02:00
Oleksandr Redko 1dcf56222d test: refactor to use WriteString (#1546) v1.47.0 2023-04-28 17:39:58 +02:00
Oleksandr Redko d2f0d17242 examples/client: fix error (#1545) 2023-04-28 17:06:45 +02:00
Oleksandr Redko 00c291ba7b pprofhandler: use bytes.HasPrefix for consistency (#1543) 2023-04-26 08:50:08 +02:00
Oleksandr Redko 1aac29366c test: use ReplaceAll, remove unnecessary else (#1542) 2023-04-25 13:17:59 +02:00
Nikolay Vedernikov cdea4fe88e Refactor client's example code (#1539)
* Refactor client's example code

* Update examples/client/client.go

Remove closure

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

---------

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
v1.46.0
2023-04-18 07:52:18 +02:00
kukayiyi 87cb886157 client:Fix DoTimeout timeout failure by setting temporary dial (#1535) 2023-04-15 13:39:32 +02:00
kinggo 43cc4870e6 fix: add noDefaultContentType copy (#1538) 2023-04-14 10:38:32 +02:00
Abe Saiovici d76662b46d Fixed transfer-encoding for empty chunked payload (#1536) 2023-04-12 22:51:30 +02:00
Anthony-Dong 6b958c2c22 support response body stream (#1414)
* feat: support response body stream

* style: add header interface

* Update http.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

* feat: support request、response、client stream

* fix: close reader bug

---------

Co-authored-by: fanhaodong.516 <fanhaodong.516@bytedance.com>
Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2023-04-05 18:56:31 +02:00
LeoSun 239cce45b1 format : update some codes style (#1533)
* update some codes style

* update adaptor.go and client.go

* Update fasthttpproxy/http.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

---------

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2023-04-04 13:48:48 -07:00
tyltr 5f4899ad5f remove (#1534) 2023-04-04 19:05:04 +02:00
Moritz Poldrack d0f2727a4d get rid of some panics (#1526)
* 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-03-30 03:38:28 +02:00
tyltr 5209cc3077 optimize:reduce loop (#1532) 2023-03-28 05:49:25 +02:00
Oleksandr Redko 0be5a4150c test: simplify bytes.Buffer declaration (#1523) 2023-03-18 14:40:25 +01:00
Oleksandr Redko faf565e222 GitHub actions/setup-go@v4 (#1520) 2023-03-18 14:32:31 +01:00
Erik Dubbelboer 53e376f822 Update dependencies v1.45.0 2023-03-15 14:50:58 +01:00
Oleksandr Redko b334443d63 docs: add missing dot to ConvertRequest comment (#1516) 2023-03-14 22:37:04 +01:00
Oleksandr Redko a281f1d21f client: HostClient.Do hangs out when ErrConnPoolStrategyNotImpl (#1515) 2023-03-14 22:36:38 +01:00
Oleksandr Redko 7846101dc6 client: fix Do hangs when configure host client fails (#1514) 2023-03-11 17:48:33 +01:00
Erik Dubbelboer 9c0e39f092 Fix proxy auth bug
fixes #1513
2023-03-08 20:13:22 +01:00
Oleksandr Redko a9d57a9461 client: remove unused go:build comment (#1511) 2023-03-06 17:08:11 +01:00
Oleksandr Redko 498a814fbf test: fix typos in function, error message, comment (#1512) 2023-03-06 16:55:21 +01:00
Oleksandr Redko 4ca6994c93 test: use Fprintf to simplify writing headers (#1510) 2023-03-06 11:13:37 +01:00
Igor Menshenin 74a050705b Immediately return ErrTimeout if deadline is already reached. (#1497)
* fix: Immediately return ErrTimeout if deadline is already reached.

* test: Added tests for negative timeout

---------

Co-authored-by: Igor Menshenin <igor@native.rent>
2023-03-03 21:25:39 +01:00
dependabot[bot] 559d536fd4 Bump golang.org/x/crypto from 0.0.0-20220214200702-86341886e292 to 0.1.0 (#1508)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20220214200702-86341886e292 to 0.1.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/commits/v0.1.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-03 20:50:27 +01:00
Oleksandr Redko 4e8c92b2ef http.go: close form file if copyZeroAlloc fails (#1498) 2023-03-03 20:48:32 +01:00
dependabot[bot] 8800d4b993 Bump golang.org/x/net from 0.0.0-20220906165146-f3363e06e74c to 0.7.0 (#1503)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.0.0-20220906165146-f3363e06e74c to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/commits/v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-03 18:21:34 +01:00
dependabot[bot] c8d2e0e6d2 Bump golang.org/x/text from 0.3.7 to 0.3.8 (#1502)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.7 to 0.3.8.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.3.7...v0.3.8)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-03 17:46:24 +01:00
cui fliter ac631aa4eb fix functiom name (#1505)
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-03-03 17:43:44 +01:00
Oleksandr Redko 2ab79063af test: bind to localhost instead of all interfaces (#1495)
Co-authored-by: Oleksandr Redko <oleksandr.redko@clarity-ag.net>
2023-02-15 11:56:23 +01:00
Oleksandr Redko b79a03aaf9 test: close response body (#1496) 2023-02-15 11:54:23 +01:00
Oleksandr Redko 9230a3dd7a docs: Deprecate ErrAlreadyServing as never returning (#1491) 2023-02-13 10:44:47 +08:00
Oleksandr Redko e15a810a98 docs: fix grammar issues and typos in comments (#1492) 2023-02-13 10:43:44 +08:00
Oleksandr Redko 5147cecec7 docs: replace links to golang.org with go.dev (#1489)
- Replace https://godoc.org with https://pkg.go.dev.
- Replace https://golang.org with https://go.dev.
- Replace https://golang.org/pkg with https://pkg.go.dev.
- Replace https://blog.golang.org with https://go.dev/blog.
- Use https://pkg.go.dev/golang.org/x/net/http2  instead of non-existing https://http2.golang.org/.
- Remove trailing slashes.
2023-02-11 19:59:44 +08:00
Oleksandr Redko 934f04e330 Refactor golangci-lint config and remove redundant nolints (#1486)
* 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
2023-02-11 15:35:15 +08:00
Oleksandr Redko f84e2346ba Rename unexported funcs, vars to match common Go (#1488)
See https://github.com/golang/go/wiki/CodeReviewComments#initialisms
and https://go.dev/doc/effective_go#mixed-caps
2023-02-10 21:34:49 +08:00
Oleksandr Redko f111c7e548 Add missing fasthttp prefix in example usage (#1487) 2023-02-10 18:18:30 +08:00
Oleksandr Redko 8dcbc41e37 test: use T.TempDir instead of MkdirTemp (#1485)
* test: use T.TempDir instead of MkdirTemp

* Fix test by adding reader.ff.Release()
2023-02-10 18:17:56 +08:00
Oleksandr Redko c0c5f9cd38 doc,test: correct typos (#1484) 2023-02-09 09:29:28 +01:00
orangesobeautiful b0fe6f00d2 optimized b2s function (#1483) 2023-02-08 08:24:24 +01:00