Commit Graph

1254 Commits

Author SHA1 Message Date
Erik Dubbelboer 079f39bddc Don't allow ASCII control character in URLs (#790)
* Don't allow ASCII control character in URLs

* Add tests
2020-04-25 20:54:59 +02:00
Ivan Mironov 3e27d8ebad Fix integer overflow handling in parseUintBuf() (#789)
* Add more tests for parseUintBuf()

* Fix integer overflow handling in parseUintBuf()
2020-04-23 15:08:07 +02:00
Erik Dubbelboer 571315f30a Only base64 the proxy auth once 2020-04-23 15:05:56 +02:00
Erik Dubbelboer 503e363eb4 Remove unnecessary check
Fixes #785
2020-04-21 09:17:34 +02:00
Erik Dubbelboer 54df169029 Add fasthttpproxy.FasthttpHTTPDialer v1.12.0 2020-04-20 18:32:19 +02:00
Erik Dubbelboer 96a8ad6e00 Upgrade dependencies 2020-04-20 18:21:58 +02:00
Kirill Danshin 5ce12a8e78 oss-security got new email
Signed-off-by: Kirill Danshin <kirill@danshin.pro>
2020-04-19 03:12:28 +03:00
Kirill Danshin f9ef8fc47b update the docs
Signed-off-by: Kirill Danshin <kirill@danshin.pro>
v1.11.0
2020-04-19 00:44:47 +03:00
Kirill Danshin cc407796cd fix: s.concurrency stays 0 when you don't use s.ServeConn
Signed-off-by: Kirill Danshin <kirill@danshin.pro>
2020-04-19 00:44:47 +03:00
Markmerc db18810c87 Add configuration to not pre-parse multipart form data (#778)
Co-authored-by: Mercurio <mmmercur@amazon.com>
v1.10.0
2020-04-14 18:17:57 +02:00
Darío 402e095d4d Fixed case when no hijacker is added but no-response is true (#772) 2020-04-07 09:35:05 +02:00
Vic Shóstak ea20759cf1 Add third-party framework to README (#774) 2020-04-07 09:33:46 +02:00
Darío a1cfe58ca8 Added fastws (alphabetically) to related projects (#770) 2020-04-03 17:30:28 +02:00
Daniel Qian 70b1d3bce7 feat: make client to wait when no free connections (#764)
* feat: make client to wait when no free connections

* feat: make client to wait when no free connections

use AcquireTimer to do timeout instead of using context

* feat: make client to wait when no free connections

Add BenchmarkClientGetEndToEndWaitConn* to test heap allocation
in waiting for free connection situation

* feat: make client to wait when no free connections

Add BenchmarkHTTPClientGetEndToEndWaitConn* to test heap allocation
in waiting for free connection situation

* feat: make client to wait when no free connections

fix bug in BenchmarkHTTPClientGetEndToEndWaitConn*

* feat: make client to wait when no free connections

fix bug in TestHostClientMaxConnWaitTimeoutSuccess make it wait
longer to avoid ErrNoFreeConns on travis-ci

* feat: make client to wait when no free connections

fix do not compile benchmark(NetHTTP?)ClientGetEndToEndWaitConn
if go version < 1.11.x

* feat: make client to wait when no free connections

fix the bug that if deadline is earlier than MaxConnWaitTimeout,
still wait MaxConnWaitTimeout which later than deadline.

* feat: make client to wait when no free connections

fix race condition in TestHostClientMaxConnWaitTimeoutError

* feat: make client to wait when no free connections

fix bug in TestHostClientMaxConnWaitTimeoutWithEarlierDeadline
2020-04-03 17:12:50 +02:00
Erik Dubbelboer 0ba26f7b42 Don't retry requests with a BodyStream
We won't be able to re-read the body stream. So instead return an error.

Fixes #766
2020-03-30 22:33:31 +02:00
Tomás Senart 75c6008129 client: Implement DoRedirects (#765)
This commit adds a `DoRedirects` method to both `HostClient` and
`Client` as well as top level convenience function of the same name that
is called with the package level `defaultClient`.

Re-implementing this redirect logic in user code is harder than
necessary.
2020-03-25 17:55:13 +01:00
Andy Pan 38aa88ab52 Make the prefork mode more robust (#755)
* Make the prefork mode more robust

The main process will exit if one of the prefork child processes doesn't complete successfully under the current prefork mode, so it ought to make sure that all child processes run independently and the main process will only exit after all child processes are finished.

* Start over those failed child processes automatically

* Kill all child processes before main process exits

* Remove redundant code

* Add configurable threshold of starting over child processes

* Return a error of RecoverThreshold

* Resolved requested changes

* Add logs

* Resolve requested changes
2020-03-13 11:25:52 +01:00
Andy Pan 0b933084a0 Resolve the security issue of GoSec (#762)
Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2020-03-13 11:25:27 +01:00
phuslu b71c8c513c Add support for NoDefaultDate option that excludes the sending of the Date header (#758) 2020-03-13 11:00:44 +01:00
Erik Dubbelboer 11e8301d6c Add LocalAddr to TCPDialer 2020-03-10 12:28:47 +01:00
RENAN.BASTOS 695f713fcf feat: workflow to verify security using GoSec (#747)
* feat: workflow to valid security using GoSec

* Update security.yml

* Fix gosec problems

These are all either false positives or os.Open operations done on
filenames supplied by the fasthttp user which we have to assume is safe.

* Just ignore some rules globally

* Fix more warnings

* No more warnings

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2020-02-28 21:03:48 +01:00
Erik Dubbelboer b9d2e961aa Run tests on 1.14 2020-02-28 19:31:53 +01:00
Erik Dubbelboer 76b74e34c2 Don't send the fragment/hash/# part of a URL to the server
Fixes https://github.com/valyala/fasthttp/issues/748
2020-02-28 18:56:02 +01:00
Sergio Andrés Virviescas Santana aa96a4709d Add prefork utility (#741) 2020-02-12 13:51:27 +01:00
Erik Dubbelboer 021c821992 Fix NetHTTPServerGet benchmarks
Fixes https://github.com/valyala/fasthttp/issues/742
2020-02-11 19:19:59 +01:00
Forest Gagnon b8803fe95d increase correctness of open conn count (#738)
Currently, it appears that GetOpenConnectionsCount underreports the
count by 1 after Shutdown has been called. This leads to a confusing
value when servers are gracefully terminating. For instance, if a server
is stuck in graceful termination, and there is one open connection
keeping it alive, GetOpenConnectionsCount would report zero.

This fix removes the decrement while the server is shutting down. It is
not perfect due to the use of two sequential atomic loads, but in the
common case it should return a more correct value overall.
2020-02-07 20:32:31 +01:00
Erik Dubbelboer 69d5c3721a Client should return ErrTimeout on timeout (#736)
Not ErrConnectionClosed which is incorrect.

Fixes: https://github.com/valyala/fasthttp/issues/355
v1.9.0
2020-01-31 22:21:00 +01:00
Fenny 38e068a51c Fix XHR Typo (#735)
* Add third-party router / framework to README.md

* Fix XHR header

* Don't add fiber to the readme yet

 It needs more users and activity first. We don't just want to add any framework otherwise our readme will get super full.

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2020-01-31 21:38:50 +01:00
Erik Dubbelboer b0102c9eba Support calling Serve multiple times on a Server (#731)
You can use the following methods in the handler to find out which
listener the connection is coming in on.
RequestCtx.IsTLS()
RequestCtx.LocalAddr()
RequestCtx.Request.Header.Host()
2020-01-23 18:30:36 +01:00
Erik Dubbelboer 03813ae4bc Fix TCPDialer is not setting ZoneID
Fixes https://github.com/valyala/fasthttp/issues/724
v1.8.0
2020-01-12 12:59:21 +01:00
Andy Pan 59b28fe0e5 Resolve code issues from goreportcard.com (#725) 2020-01-12 12:57:42 +01:00
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