Commit Graph

1391 Commits

Author SHA1 Message Date
tyltr ba401075d3 compatible with new build tag (#1087) 2021-09-02 00:18:53 +02:00
tyltr d9c75732a6 improve invalidStatusLine by appending a []byte directly (#1086)
* improve invalidStatusLine

* append []byte directly

* AppendUint

* negetive

* AppendInt
2021-09-01 19:27:14 +02:00
Andy Pan cad867ad92 Remove the redundant badage (#1085) 2021-09-01 12:28:46 +02:00
Erik Dubbelboer 38992dafcf Fix []byte reuse bug
The return value of normalizePath should be a reusable []byte.
Returning strSlash could cause the strSlash constant to be reused and
resulted in very weird behavior. This specific case of normalizePath
almost never happens which made it even harder to spot.

The race detector on Windows was the only clue that something was
happening:

WARNING: DATA RACE
Write at 0x000001d082e3 by goroutine 446:
  github.com/valyala/fasthttp.addLeadingSlash()
      D:/a/fasthttp/fasthttp/uri_windows.go:8 +0xa5
  github.com/valyala/fasthttp.normalizePath()
      D:/a/fasthttp/fasthttp/uri.go:343 +0xbd
  github.com/valyala/fasthttp.(*URI).parse()
      D:/a/fasthttp/fasthttp/uri.go:314 +0x1606
  github.com/valyala/fasthttp.(*URI).Parse()
      D:/a/fasthttp/fasthttp/uri.go:266 +0xb3
  github.com/valyala/fasthttp.testURIPathNormalize()
      D:/a/fasthttp/fasthttp/uri_test.go:195 +0x47
  github.com/valyala/fasthttp.TestURIPathNormalize()
      D:/a/fasthttp/fasthttp/uri_test.go:176 +0x38e
  testing.tRunner()
      C:/hostedtoolcache/windows/go/1.15.15/x64/src/testing/testing.go:1123 +0x202

Previous read at 0x000001d082e3 by goroutine 332:
  runtime.slicecopy()
      C:/hostedtoolcache/windows/go/1.15.15/x64/src/runtime/slice.go:246 +0x0
  github.com/valyala/fasthttp.(*RequestHeader).AppendBytes()
      D:/a/fasthttp/fasthttp/header.go:1726 +0x24d
  github.com/valyala/fasthttp.(*RequestHeader).Header()
      D:/a/fasthttp/fasthttp/header.go:1698 +0x84
  github.com/valyala/fasthttp.(*RequestHeader).Write()
      D:/a/fasthttp/fasthttp/header.go:1682 +0x10f
  github.com/valyala/fasthttp.(*Request).Write()
      D:/a/fasthttp/fasthttp/http.go:1370 +0x1ab
  github.com/valyala/fasthttp.testRequestSuccess()
      D:/a/fasthttp/fasthttp/http_test.go:1788 +0x32a
  github.com/valyala/fasthttp.TestRequestSuccess()
      D:/a/fasthttp/fasthttp/http_test.go:1678 +0x2dd
  testing.tRunner()
      C:/hostedtoolcache/windows/go/1.15.15/x64/src/testing/testing.go:1123 +0x202
2021-08-28 11:54:58 +02:00
Erik Dubbelboer 63211032d4 Various deadline fixes (#1081) 2021-08-28 11:19:32 +02:00
Erik Dubbelboer 51508d7480 Fix various Windows Github Action errors (#1082)
* Fix various Windows Github Action errors

These tests keep giving errors because Windows Actions are slower.

* Remove some timeouts

We don't need timeouts in all tests, only in the ones where we are
actually testing timeout logic.
2021-08-28 09:42:38 +02:00
YenForYang c7ce95f778 Fix s2b (#1079)
Ensure `len(b)` <= `cap(b)` at all times. Additionally, use `runtime.KeepAlive()` to prevent `s` from being GC-ed.
2021-08-26 10:09:45 +02:00
Erik Dubbelboer a50f59be52 Increase various test timeouts
Github workers on windows are slow.
2021-08-24 11:18:22 +02:00
Lanco 0fe8cddd97 Optimize size of Server by moving bool fields (#1077) 2021-08-23 11:27:51 +02:00
Erik Dubbelboer a6f9c8a442 Fix Client doc and mCleaner (#1076)
- Reduce mCleaner goroutine time.
- Add comment about changing Client fields while in use.
2021-08-20 14:52:06 +02:00
Erik Dubbelboer 5a6e6e102b Add Go 1.17 support (#1074)
* Add Go 1.17 support

* Increase test timeouts
2021-08-18 21:38:21 +02:00
Mikhail Faraponov 97e1319927 Update compress (#1069) v1.29.0 2021-08-16 18:09:31 +02:00
Erik Dubbelboer 0263cae5a2 Fix FasthttpSocksDialer example 2021-08-14 10:28:45 +02:00
Tianyi Song d31e6dbdba Handle perIPConn in RequestCtx.IsTLS() specially (#1064) 2021-08-04 20:15:05 +02:00
Kazumasa Takenaka (Bamboo) 9466cd7657 fix typo: occured -> occurred (#1061) 2021-07-17 17:51:59 +02:00
Darío b3ece39dcd Update README.md (#1058) 2021-07-08 09:55:08 +02:00
Sujit Baniya d0df1e1dde Add ResetUserValues() and test (#1056) 2021-07-01 10:57:21 +02:00
Erik Dubbelboer 1504a84ed7 Increase TestHostClientMaxConnWaitTimeoutSuccess timeout v1.28.0 2021-06-29 09:36:30 +02:00
Erik Dubbelboer f6560bebb2 Flush buffered responses if we have to wait for the next request (#1050)
* Flush buffered responses if we have to wait for the next request

Don't wait for the next request as this can take some time, instead
flush the outstanding responses already.

Fixes #1043

* Only peek 1 byte

Make sure old clients that send bogus \r\n still work.
See: https://github.com/golang/go/commit/bf5e19fbaf02b1b25fbe50c27ec301fe830a28d0
2021-06-28 17:38:39 +02:00
Erik Dubbelboer 874c8cad76 Increase timeouts for Windows github actions v1.27.0 2021-06-18 15:46:40 +02:00
Erik Dubbelboer 924a63fdeb Increase TestServerTLSReadTimeout timeout
And TestFSCompressConcurrent timeout
2021-06-18 15:41:42 +02:00
Erik Dubbelboer 410bde6009 Fix race condition in TestPipelineClientIssue832 2021-06-18 15:28:58 +02:00
Erik Dubbelboer 9f2c63676d Lower go test time 2021-06-18 14:57:18 +02:00
Meng 4ed933a2e7 fix: set content-length properly when StreanRequestBody was enabled (#1049)
* fix: set content-length properly when StreanRequestBody was enabled

* fix: add test cases for validating content length of streaming request
2021-06-18 13:43:29 +02:00
Erik Dubbelboer cec99537fe Add IdleTimeout to Shutdown documentation 2021-06-18 13:38:17 +02:00
Ertuğrul Emre Ertekin c12a06108b TCPDialer :: DNSCacheDuration option (#1046)
* DefaultDNSCacheDuration :: Changed to `var`

* Revert "DefaultDNSCacheDuration :: Changed to `var`"

This reverts commit d836eace9f.

* TCPDialer :: DNSCacheDuration option

* TCPDialer :: DNSCacheDuration option - comment added

* TCPDialer :: DNSCacheDuration option - comment fixed
2021-06-18 13:37:07 +02:00
Erik Dubbelboer 87fc95849c Run go test on github actions (#1047)
* Run go test on github actions

travis-ci.org has stopped.
See also: https://github.com/curl/curl/issues/7150

Downside: github actions don't support ppc64le

* Run less

* delete .travis.yml

* Remove travis + minor lint fixes
2021-06-18 13:36:54 +02:00
Darío be13b504ab Defined Transport for the client (#1045)
* Defined Transport for the client

* Added Transport test
2021-06-16 12:55:56 +02:00
Erik Dubbelboer b8b065b0d7 Don't unwrap io.LimitedReader
This is not needed anymore to trigger sendfile. The Go wrapper around
sendfile already does this: https://github.com/golang/go/blob/9d46ee5ac4acd6602692f70c5149a3f6db058558/src/net/sendfile_linux.go#L23-L33
2021-06-12 13:16:36 +02:00
Erik Dubbelboer 6233fbc08e Fix header .Add functions (#1036)
These functions should take the headers that are handled differently
into account.
v1.26.0
2021-06-01 10:52:35 +02:00
Erik Dubbelboer 5bb5cfc9ca Remove unused peekRawHeader 2021-05-26 09:09:50 +02:00
Sergio Andrés Virviescas Santana 7d13e18a4f Add Request.TLS and try to avoid a new alloc if Request.Header is already allocated (#1034) 2021-05-26 09:06:37 +02:00
Sergio Andrés Virviescas Santana b433ecfcbd Make sure to reset the userValues always and at the exact time (#1027)
* Ensure reset userValues always that release RequestCtx

* Reset userValues after response write and hijack handler are executed
2021-05-22 17:23:41 +02:00
Erik Dubbelboer a18c6322a2 Fix cookie panic 2021-05-21 12:11:09 +02:00
Erik Dubbelboer f3e4118c5b Don't recommend Go 1.13 2021-05-21 11:59:58 +02:00
Sergio Andrés Virviescas Santana fa3e5d85f2 Run test with go 1.16.X (#1028)
* Run test with go 1.16.X

* Fix min required go version

* Add go tip

* Update .github/workflows/security.yml

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

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
v1.25.0
2021-05-17 10:45:11 +02:00
MoreFreeze ffa0cabed8 Use proper content-type when it is not present (#1023)
Co-authored-by: liuchenxing <liuchenxing@bytedance.com>
2021-05-17 09:20:18 +02:00
Nícolas Barbosa 04cde74c41 feature: add ConvertRequest func (#1024)
* feature: add ConvertRequest func

To easy method to convert ctx.RequestCtx to http.Request

* chore: minor changes by code review #1024
2021-05-17 09:20:10 +02:00
Sergio Andrés Virviescas Santana 5898006f5b Upgrade dependencies and tidy (#1029) 2021-05-17 09:12:49 +02:00
MoreFreeze 097fa05a69 Fix ignoreBody still set content length (#1022)
* Fix ignore body should not set content-length

* Add TestRequestReadNoBody

Co-authored-by: liuchenxing <liuchenxing@bytedance.com>
2021-05-14 10:08:51 +02:00
Juan Chan b2f111bd98 Fix(adaptor): Fixed an issue where the adapter did not convert all (#1021)
values of the header successfully when converting the header.
2021-05-11 09:58:25 +02:00
Roman Khimov 19fcd40863 Fix chunked streaming (#1015)
* http: refactor out crlf reading function

Make it a bit simpler and make it reusable.

* streaming: fix chunked stream test

This test is supposed to check for stream unchunking, but it's not really
effective with that because chunks created by createChunkedBody() get wrapped
into another chunk by writeBodyStream(), so we end up with chunkedBody in
request handler although what we really want is plain body.

Deduplicate test and benchmark also.

* streaming: fix Read interface

It wasn't actually compatible with io.Reader as io.Reader _never_ returns n >
len(p) while this function easily did that for chunked payloads confusing its
users:

panic: runtime error: slice bounds out of range [:528] with capacity 512

goroutine 562 [running]:
io.ReadAll(0x9f4380, 0xc0003be1a0, 0xc0004fcd80, 0x0, 0x0, 0xc00086bc30, 0x46f99b)
        /usr/lib64/go/1.16/src/io/io.go:634 +0x205
io/ioutil.ReadAll(...)
        /usr/lib64/go/1.16/src/io/ioutil/ioutil.go:27
github.com/valyala/fasthttp.getChunkedTestEnv.func1(0xc001fdc680)
        /home/rik/dev/fasthttp/streaming_test.go:108 +0x6c
github.com/valyala/fasthttp.(*Server).serveConn(0xc000416d80, 0xa034e8, 0xc0004da880, 0x0, 0x0)
        /home/rik/dev/fasthttp/server.go:2219 +0x12ee
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc000148960, 0xc0003be160)
        /home/rik/dev/fasthttp/workerpool.go:223 +0xba
github.com/valyala/fasthttp.(*workerPool).getCh.func1(0xc000148960, 0xc0003be160, 0x8b4ec0, 0xc0003be160)
        /home/rik/dev/fasthttp/workerpool.go:195 +0x35
created by github.com/valyala/fasthttp.(*workerPool).getCh
        /home/rik/dev/fasthttp/workerpool.go:194 +0x11f

It also returned len(p) in some cases where it read less than that.
2021-05-04 12:55:54 +02:00
Lauris BH 620f0c83ad Add option for middleware to set custom remote address (#1009)
* Add option for middleware to set custom remote address

* Update Init2 to clear custom context remoteAddr
v1.24.0
2021-04-23 13:25:02 +02:00
Lauris BH 894272e578 Fix golangci-lint action (#1010) 2021-04-23 09:17:45 +02:00
Daniel Firsht 2a6f7db5bb Adding support for securing error logs (#1001)
Co-authored-by: Daniel Firsht <firsht@amazon.com>
v1.23.0
2021-03-26 10:46:57 +01:00
Mikhail Faraponov e61c9d5d3c Improve Client/HostClient pooling when many HostClient structs created and removed during program execution (#1000)
* Update client.go

* Update client.go
2021-03-25 22:47:39 +01:00
Mike Faraponov a5830066b6 Use bytes.IndexByte instead of bytes.Index for single byte lookup (#999)
* Update uri.go

* Update strings.go
2021-03-20 15:57:57 +01:00
blanet 860c345f10 Fix unexpected panic when calling Do of a PipelineClient (#997)
* fix: Unexpected panic for PipelineClient

PipelineClient would panic when calling `Do` with a nil Response as
the second parm

This commit fixes the unexpected panic by checking nil first before
setting fields for Response

* Add tests to ensure nil resp is valid for PipelineClient
2021-03-17 21:26:56 +01:00
Vladimir Shteinman 0cd7349686 ImmediateHeaderFlush when no body (#995) 2021-03-15 18:10:51 +01:00
kiyon 02e0722fb7 Add PipelineClient name (#994)
* Improve documentation about DelClientCookie which related with #951.

* Add pipeline name
2021-03-15 17:46:16 +01:00