* 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
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.
* 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
* 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>
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.
* 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>
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()
* 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
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%
* 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