Commit Graph

1223 Commits

Author SHA1 Message Date
Lovro Mažgon 8d8443d77c Forward context in fasthttpadaptor (#720)
* forward context in fasthttpadaptor

* run go fmt
2020-01-10 16:41:16 +01:00
谷月轩 16c53d6b04 Set StatusRequestTimeout when net timeout error occurred (#713) 2019-12-31 12:23:27 +01:00
Erik Dubbelboer 958ed36194 Allow no response to be send when a connection is hijacked (#712)
* Allow no response to be send when a connection is hijacked

At the moment there is always a HTTP response before the connection gets
hijacked. This second option to Hijack() prevents this response from
being send.

Fixes: https://github.com/valyala/fasthttp/issues/698

* Add HijackSetNoResponse method instead
v1.7.1
2019-12-29 11:34:55 +01:00
Erik Dubbelboer 0724b3e064 Update LICENSE formatting
For https://pkg.go.dev/github.com/valyala/fasthttp?tab=licenses we need
to match the MIT license more accurately in formatting.

See: https://play.golang.org/p/n_ZHW4KMhaI
2019-12-25 11:39:28 +01:00
Erik Dubbelboer 415e5fc531 Fix panic in header parser v1.7.0 2019-12-14 22:20:09 +01:00
Erik Dubbelboer fd55658938 Improve multiline header parsing (#708)
- Replace tabs with spaces at line starts to match net/http
- Don't allow multi line header names. See: https://github.com/golang/go/issues/34702
2019-12-14 10:58:06 +01:00
tedli 6a8a72ac18 add extra checking of header buffer, to support multi line header value (#123) (#688) 2019-12-14 09:45:35 +01:00
Erik Dubbelboer a266a926ae Only show master branch on travis-ci 2019-12-01 10:45:29 +01:00
Erik Dubbelboer 6cccaebf64 Fix parsing relative URLs starting with // (#702)
* Fix parsing relative URLs starting with //

* Improve test
2019-12-01 09:44:21 +01:00
Erik Dubbelboer 39dd1045bb Allow a body for GET requests (#703)
This means we can't skip parsing headers for GET requests anymore. This
can be seen as good as it also allows us to reject malformed GET
requests, something we didn't do before this. Performance also isn't
affect much:

benchmark                                            old ns/op     new ns/op     delta
BenchmarkClientGetEndToEnd1Inmemory-16               640           641           +0.16%
BenchmarkClientGetEndToEnd10Inmemory-16              713           710           -0.42%
BenchmarkClientGetEndToEnd100Inmemory-16             732           749           +2.32%
BenchmarkClientGetEndToEnd1000Inmemory-16            759           774           +1.98%
BenchmarkClientGetEndToEnd10KInmemory-16             785           808           +2.93%
BenchmarkNetHTTPClientGetEndToEnd1Inmemory-16        5045          4954          -1.80%
BenchmarkNetHTTPClientGetEndToEnd10Inmemory-16       5806          6225          +7.22%
BenchmarkNetHTTPClientGetEndToEnd100Inmemory-16      7877          7998          +1.54%
BenchmarkNetHTTPClientGetEndToEnd1000Inmemory-16     16603         16559         -0.27%
2019-12-01 09:44:11 +01:00
Nikolay Markov bc5b479d85 Custom LookupIPAddr function (#699)
* Custom LookupIPAddr function
* use interface instead of pointer
2019-11-25 15:21:03 +01:00
Erik Dubbelboer 32de06dba4 Don't start a goroutine when not needed
sync.Once only has the overhead of a single atomic.LoadUint32

Fixes #693
2019-11-16 18:10:44 +01:00
Erik Dubbelboer 32793db72d Run golangci-lint using a Github Action 2019-11-16 18:09:28 +01:00
Erik Dubbelboer 5f66658800 Add Client.MaxConnDuration 2019-11-10 20:04:54 +01:00
Nikolay Markov 3fb2eba209 Ability to pass custom DNS resolver to TCPDialer (#689)
* Ability to pass custom DNS resolver to TCPdialer

* Update tcpdialer.go

Co-Authored-By: Erik Dubbelboer <erik@dubbelboer.com>
2019-11-10 19:59:21 +01:00
Vladimir Shteinman 70223a183c Recover from panic in body write (#687)
* Recover from panic in body stream write

* CR + Add tests
2019-11-06 14:35:52 +01:00
Andy Pan 87c4546c7b Add a badge for showing projects that use fasthttp (#685) 2019-10-28 23:05:41 +08:00
Andy Pan 4489df89cb Update "TechEmpower Benchmark" from round 12 to round 18 (#683)
* Update "TechEmpower Benchmark" from round 12 to round 16

* Update "TechEmpower Benchmark" to round 18
v1.6.0
2019-10-28 12:01:28 +08:00
Andy Pan 9f11af2968 Make several optimizations to worker pool (#680)
* Use binary-search algorithm to speed up cleaning up workers

* Speed it up when iterating the slice of workerChan

* Use sync.Pool as a more canonical way

* Add benchmark test between binary-search and linear search

* Optimize range to the slice of workerChan, avoiding elements copy

* Perfect the benchmark of work pool

* Make binary-search code inline and remove benchmark test code
2019-10-28 02:27:31 +08:00
Kevin Burns f82a6460e9 Requests with incomplete bodies no longer cause log noise (#682)
* #660 Incorrect content length

* fix

* unexpected EOF is expected

* Prevent test from panicing should err ever be nil
2019-10-27 15:29:20 +08:00
alexDango 9bc6da1219 fix: when multipartform no data,FormValue do not panic (#677) 2019-10-25 14:55:11 +08:00
ZhangYunHao 707b1c1917 Format errors (#679)
* format errors

* Server is a type name

* Fix typo
2019-10-23 20:12:59 +08:00
ZhangYunHao 18c619fb04 fasthttputil: add errInmemoryListenerClosed (#678)
* add errInmemoryListenerClosed

* Fix test error

* Expose ErrInmemoryListenerClosed

* rename
2019-10-22 15:55:44 +08:00
Erik Dubbelboer bf98e3b75b Use least total connections instead of round robin for lbclient (#673) 2019-10-20 07:09:42 +02:00
Erik Dubbelboer ec2e3965a4 Don't run TestClientNilResp in parallel 2019-10-19 22:34:56 +02:00
Erik Dubbelboer d428e1b05e Fix race condition in tests, fix URI bug
- Some tests can't be run in parallel.
- `URI` had a pointer to `RequestHeader` which was updated with
`RequestHeader.CopyTo` which resulted in the URI pointing to the wrong
`RequestHeader` causing bugs and race conditions.

The only reason `URI` contained a pointer to `RequestHeader` was to delay the
call to `RequestHeader.Host()` until really needed. But these days instead
of parsing all headers, `RequestHeader.Host()` uses
`RequestHeader.peekRawHeader()` which is rather fast. So we can remove the
pointer in `URI` and completely decouple the two structs improving code
quality and fixing the bug.

For some reason this results in faster code on average as well:
benchmark                                          old ns/op     new ns/op     delta
BenchmarkClientGetEndToEnd1Inmemory-8              1189          1369          +15.14%
BenchmarkClientGetEndToEnd10Inmemory-8             1143          1161          +1.57%
BenchmarkClientGetEndToEnd100Inmemory-8            1228          1236          +0.65%
BenchmarkClientGetEndToEnd1000Inmemory-8           1213          1213          +0.00%
BenchmarkClientGetEndToEnd10KInmemory-8            1362          1350          -0.88%
BenchmarkClientEndToEndBigResponse1Inmemory-8      139967        130070        -7.07%
BenchmarkClientEndToEndBigResponse10Inmemory-8     142233        131809        -7.33%
BenchmarkServerGet1ReqPerConn-8                    1726          1593          -7.71%
BenchmarkServerGet2ReqPerConn-8                    882           927           +5.10%
BenchmarkServerGet10ReqPerConn-8                   440           436           -0.91%
BenchmarkServerGet10KReqPerConn-8                  341           339           -0.59%
BenchmarkServerPost1ReqPerConn-8                   1728          1706          -1.27%
BenchmarkServerPost2ReqPerConn-8                   968           963           -0.52%
BenchmarkServerPost10ReqPerConn-8                  506           505           -0.20%
BenchmarkServerPost10KReqPerConn-8                 424           420           -0.94%
BenchmarkServerGet1ReqPerConn10KClients-8          1117          1051          -5.91%
BenchmarkServerGet2ReqPerConn10KClients-8          565           514           -9.03%
BenchmarkServerGet10ReqPerConn10KClients-8         390           387           -0.77%
BenchmarkServerGet100ReqPerConn10KClients-8        355           348           -1.97%
BenchmarkServerHijack-8                            339           348           +2.65%
BenchmarkServerMaxConnsPerIP-8                     326           325           -0.31%
BenchmarkServerTimeoutError-8                      24355         24180         -0.72%
2019-10-19 21:02:31 +02:00
Erik Dubbelboer c3d82ca3a4 Speed up testing by running tests in parallel 2019-10-16 10:20:13 +02:00
Erik Dubbelboer 352ec7c83e Use Fatal instead of Fatalf when no formatting used 2019-10-16 10:20:13 +02:00
Erik Dubbelboer 9dbe5fc77c Don't allow spaces in request header keys
See: https://github.com/golang/go/commit/6e6f4aaf70c8b1cc81e65a26332aa9409de03ad8

Reject any non GET or HEAD requests with a 400.

We can't reject GET or HEAD requests with bad headers as we delay
parsing of these headers until the user asks for one. So in this case we
just ignore the header and don't return a value for it.
2019-10-16 10:20:13 +02:00
Erik Dubbelboer 4ebe993965 Document PipeConns not being safe for concurrent use 2019-10-16 10:20:13 +02:00
rogercarter1 044d35e5ef fix 664 (#674) 2019-10-16 16:18:52 +08:00
Ian Leue ffcdb753b1 Allow client to disable path normalization (#672) 2019-10-11 14:20:29 +08:00
Erik Dubbelboer af531ad4c0 Move comment to now show up on godoc
Comments above the package statement show up at the top of
https://godoc.org/github.com/valyala/fasthttp
2019-10-03 14:08:17 +02:00
Erik Dubbelboer 28af1f13fe Fix previous commit 2019-10-02 22:40:15 +02:00
Vendin 5038ebcc55 Refactoring to reuse response status codes (#666)
* Refactoring to reuse response status codes

* add StatusCodeIsRedirect function

* update commentary for StatusCodeIsRedirect function
2019-10-02 22:04:37 +02:00
ZhangYunHao b1ca43febc Use 'go generate' in bytesconv.go (#663)
* Add bytesconv_table_gen.go
2019-09-28 14:55:31 +02:00
Erik Dubbelboer 97d51fbf75 go fmt ./... 2019-09-28 14:53:43 +02:00
Erik Dubbelboer e6a8bcfb0c Add go version to go.mod, test with 1.13.1
I chose 1.11 for the version in the go.mod file based on the information
in this issue: https://github.com/golang/go/issues/30791
2019-09-28 10:10:20 +02:00
Erik Dubbelboer 1d6a7e0493 The Authorization header should include the Basic keyword
Thanks to https://github.com/paween1980
2019-09-27 17:29:44 +02:00
Oleg Kovalov dc9b54dbdf Precompute default regexp (#662) 2019-09-25 20:56:31 +02:00
ZYunH be93fbd21b Add lowerhex 2019-09-20 06:33:34 +03:00
ZYunH 79bd450e0e Use 0xf instead of 15 2019-09-20 06:33:34 +03:00
ZYunH 91138eed5f Replace int2hexbyte with uppercase 2019-09-20 06:33:34 +03:00
ZYunH 9bc19f85e1 Replace hexCharUpeer with upperhex (#657) 2019-09-19 13:15:51 +02:00
Kirill Danshin d644da4382 Update README.md 2019-09-18 19:20:23 +03:00
ZYunH ae421163c5 Improve appendQuotedPath and AppendQuotedArg (#654)
* Update bytesconv.go
* Modify tests
* Remove unnecessary comments
* Update args_test.go
* Add test for appendQuotedPath
* Fix 11202 issue
* Fix some problems
2019-09-18 13:52:04 +02:00
Daniel Firsht ee8450036e Added option to disable path normalization (#649) 2019-09-18 08:56:18 +02:00
Erik Dubbelboer c6037ab3b4 Update fuzzit 2019-09-16 15:03:59 +02:00
Erik Dubbelboer 8b0b919f26 Fix FasthttpSocksDialer documentation v1.5.0 2019-09-13 21:47:26 +02:00
Erik Dubbelboer b29d896c75 Fix fuzzit for Go 1.13 2019-09-12 11:07:43 +02:00