Commit Graph

1275 Commits

Author SHA1 Message Date
RW 853abb31af 🐞 panic in fs.go #824 (#825)
Co-authored-by: wernerr <rene.werner@verivox.com>
2020-06-04 16:53:47 +02:00
Andy Pan 33b3cb259e Support Windows SO_REUSEADDR (#822)
* Support Windows SO_REUSEADDR

* Update the comment

* Renew comment of the Listen method on Windows
2020-06-04 16:51:39 +02:00
Andy Pan 29e6d094c8 Update TechEmpower benchmark from 18 to 19 round (#821) 2020-06-02 11:56:48 +02:00
Erik Dubbelboer b98999e8e0 Merge pull request #820 from valyala/uri-errors
URI.Parse now returns an error
v1.14.0
2020-06-01 11:46:14 +02:00
Erik Dubbelboer 439185eb57 Run cross compilation and race detector on the latest release only 2020-05-31 17:05:49 +02:00
Erik Dubbelboer bcaa594b41 Remove unused raw header code 2020-05-31 15:49:37 +02:00
Erik Dubbelboer 9468c66e25 URI.Parse now returns an error 2020-05-31 15:16:54 +02:00
Erik Dubbelboer 1391312294 Merge pull request #817 from vural/custom-retry-decider
Add custom retry decider for fail http requests
2020-05-30 16:50:17 +02:00
Vural Kap 77dcda39ae Add custom retry decider for fail http requests 2020-05-27 20:40:04 +03:00
Erik Dubbelboer 2f92c68a07 Add timeouts to tls Handshake
Fixes #813 which suggested the code.
v1.13.0 v1.13.1
2020-05-25 20:44:04 +02:00
Erik Dubbelboer 123f6a8cee Fix memory reusage bug with auth
Fixes #814
2020-05-25 20:27:15 +02:00
Erik Dubbelboer 24410e58c0 Merge pull request #810 from valyala/brotli
Add Brotli support
2020-05-18 18:30:48 +02:00
Erik Dubbelboer d22782d3f7 HostClient can't switch between protocols (#800) 2020-05-18 18:30:29 +02:00
Moritz Marquardt 5bd1b0cf2c Make FS return a redirect for directories without trailing slash (#802)
* Make FS return a redirect for directories without trailing slash

Fixes #792

* Add a test for the directory redirect

* Fix directory redirects for ServeFile

* Fix error message

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2020-05-18 18:30:13 +02:00
Erik Dubbelboer 05d4602a68 Fix race condition in test 2020-05-16 11:54:57 +02:00
Erik Dubbelboer 339ad36634 Add Brotli support
New Functions:

    CompressHandlerBrotliLevel(h RequestHandler, brotliLevel, otherLevel int) RequestHandler
    Request.BodyUnbrotli() ([]byte, error)
    Response.BodyUnbrotli() ([]byte, error)
    AppendBrotliBytesLevel(dst, src []byte, level int) []byte
    WriteBrotliLevel(w io.Writer, p []byte, level int) (int, error)
    WriteBrotli(w io.Writer, p []byte) (int, error)
    AppendBrotliBytes(dst, src []byte) []byte
    WriteUnbrotli(w io.Writer, p []byte) (int, error)
    AppendUnbrotliBytes(dst, src []byte) ([]byte, error)

New Constants:

    CompressBrotliNoCompression
    CompressBrotliBestSpeed
    CompressBrotliBestCompression
    CompressBrotliDefaultCompression

Brotli compression levels are different from gzip/flate. Because of this we have separate level constants and CompressHandlerBrotliLevel takes 2 levels.

I didn't add Brotli support to CompressHandler as this could cause a spike in CPU usage when users upgrade fasthttp.

fasthttp.CompressBrotliDefaultCompression is not the same as
brotli.DefaultCompression. brotli.DefaultCompression is more than twice
as slow as fasthttp.CompressBrotliDefaultCompression which I thought was
unreasonable as default.
2020-05-15 15:36:26 +02:00
Erik Dubbelboer 9507d7c7d7 Don't wrap conn with a TLS Client if it's already a TLS Conn 2020-05-12 12:32:53 +02:00
Erik Dubbelboer dacd0353f9 HostClient can't switch between protocols 2020-05-02 21:01:52 +02:00
Julian Junxiang Zhou dc6b9db734 Copy to the req.Header.userAgent from the defaultUserAgent (#796)
This avoids the req.Header.userAgent sharing an underlying array with the
global defaultUserAgent

This should fix the #795
2020-04-30 13:06:48 +02:00
Mike MacDermaid 32940977fb allow the expect 100 continue workflow to deny requests (#787)
* allow the expect 100 continue workflow to deny requests

* suggested changes

* update booleans to reflect handler name change
2020-04-27 20:29:02 +02:00
Erik Dubbelboer 446e1a638d Fix .travis.yml 2020-04-26 14:58:14 +02:00
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