Commit Graph

168 Commits

Author SHA1 Message Date
Erik Dubbelboer d22782d3f7 HostClient can't switch between protocols (#800) 2020-05-18 18:30:29 +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
Erik Dubbelboer 503e363eb4 Remove unnecessary check
Fixes #785
2020-04-21 09:17:34 +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
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 69d5c3721a Client should return ErrTimeout on timeout (#736)
Not ErrConnectionClosed which is incorrect.

Fixes: https://github.com/valyala/fasthttp/issues/355
2020-01-31 22:21:00 +01:00
Andy Pan 59b28fe0e5 Resolve code issues from goreportcard.com (#725) 2020-01-12 12:57:42 +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
Ian Leue ffcdb753b1 Allow client to disable path normalization (#672) 2019-10-11 14:20:29 +08: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
Nikolay Markov 4fa45fadd2 Propagating custom SkipBody value to allow explicitly skip body reading for responses (#647) 2019-09-04 17:54:12 +02:00
Ian Leue d4833f60cb Use ipv6-compliant methodology for joining host port (#640)
* Use ipv6-compliant methodology for joining host port

* Fix change
2019-08-23 17:19:47 +03:00
Mike Faraponov ce02b85a9c Add ability to set timeout for handshake (#631)
* Fixed issue with handshake timeout
2019-08-18 14:34:47 +02:00
Erik Dubbelboer 1ee3b845b6 Fix Client.DoTimeout race condition 2019-05-23 13:15:14 +02:00
Erik Dubbelboer ea427d2f44 Fix nil Response support in Do* methods
Fixes #561
2019-04-11 19:30:20 +02:00
xuecai 10b98c2cdf add conn's address info in Response (#537)
* reset commit
* fix response copy bug; add tests;
2019-02-16 10:50:14 +00:00
Erik Dubbelboer e722d81dc9 Fix HostClient.MaxConns 2019-02-11 21:12:32 +01:00
Okunev Yu Dmitry fa7a110f3e An atomic approach for HostClient.MaxConns (#531)
An atomic approach for HostClient.MaxConns
2019-02-07 21:37:59 +00:00
Nikolay Markov 71e7652440 SkipBody is propagated to Response copy (#532) 2019-02-06 12:36:43 +03:00
xuecai 627d63dd25 change timer to public api #525 (#527)
* change acquireTimer and releaseTimer to public api
2019-02-03 19:16:39 +00:00
Erik Dubbelboer 5de7a833de Add warning to DoTimeout 2019-01-26 22:26:59 +01:00
Blless 1d2d99cba3 Add MaxIdemponentCallAttempts to fasthttp.Client (#484)
* Add MaxIdemponentCallAttempts to fasthttp.Client
2018-11-29 16:36:36 +06:30
amezghal abdelilah 8be35c8fb8 cleanup resources 2018-11-28 11:57:58 +06:30
amezghal abdelilah a3c314e4a3 cleanup 2018-11-28 11:57:58 +06:30
amezghal abdelilah 8388aaa0c6 check cleanup status using atomic 2018-11-28 11:57:58 +06:30
amezghal abdelilah 92e4256ef6 cleanup resources 2018-11-28 11:57:58 +06:30
amezghal abdelilah db09046f71 cleaup after timeout
Cleanup resources if there was a timeout
2018-11-28 11:57:58 +06:30
amezghal abdelilah 7b6cfd261a fix potential leak
cleanup in case of timeouts
2018-11-28 11:57:58 +06:30
amezghal abdelilah 80829ab6ff Make sure to always release resources
Make sure to always release resources in the event of timeout
2018-11-28 11:57:58 +06:30
zhaoxy 707bfb8c0e remove extra space 2018-11-23 12:40:08 +06:30
zhaoxy a26bbd1812 Remove the set read and write deadline optimization since golang has fixed it https://github.com/golang/go/issues/15133#issuecomment-271571395 2018-11-23 12:40:08 +06:30
zhaoxy 8a7123ed78 fix check failed 2018-11-23 12:40:08 +06:30
川宇 4570d12009 avoid empty pointer 2018-11-23 12:40:08 +06:30
川宇 c7d1f2a6d6 reset connection read and write deadline for reuse 2018-11-23 12:40:08 +06:30
Erik Dubbelboer fcaab424ca Don't retry client requests with ErrBodyTooLarge
Fixes #455
2018-11-12 13:23:42 +08:00
Erik Dubbelboer 8f4c5d5d1d Change HostClient.pendingRequest to an int32
atomic.AddUint64 needs a 64bit aligned address on x86, int32 is more
than enough and keeps the code more readable.

Fixes #451
2018-11-03 22:34:05 +08:00
Erik Dubbelboer aebec409b0 Only remove a HostClient from Client if it is unused 2018-11-01 19:05:53 +08:00
Erik Dubbelboer 192515395f Add Client.NoDefaultUserAgentHeader 2018-11-01 12:44:17 +08:00
Gabriel Pérez S 996610f021 Schema changes detection with HostClient
Related with the issue https://github.com/valyala/fasthttp/issues/244
2018-10-14 16:19:09 +03:00
Erik Dubbelboer d7688109a5 Reset all fields when releasing a clientConn
This fixes a bug where a previous read deadline timer would be reused
for a new connection preventing Client.ReadTimeout from working
properly.

See: https://github.com/valyala/fasthttp/pull/259
2018-09-01 13:20:36 +08:00
michael.kochegarov 19d2d06ab5 Configuration for automatic retry for idempotent calls 2018-08-29 22:26:04 +08:00
Erik Dubbelboer d3181922e1 Fix connsCleaner sleep time
Fixes: https://github.com/valyala/fasthttp/issues/308
2018-08-27 21:49:31 +00:00
Erik Dubbelboer 6c79939960 Fix Get/Post documentation
The functions don't append to dst, they overwrite.
2018-08-27 21:30:43 +00:00
Erik Dubbelboer 2f0f8a4824 Fix supported redirect status codes
Support the same redirect status codes as the golang standard library
does: https://github.com/golang/go/blob/15095be9fbe726d4a3ef43b68d2fbc83e6484ded/src/net/http/client.go#L419
2018-08-24 15:56:55 +03:00