Commit Graph

1123 Commits

Author SHA1 Message Date
Erik Dubbelboer aaec9b0fe2 Make InmemoryListener.Dial return when the connection is accepted
This makes InmemoryListener deterministic which makes our tests much
less flacky under high load or when GOMAXPROCS=1
2019-02-02 23:40:05 +01:00
Erik Dubbelboer 51532b9517 Shutdown close channel returned by RequestCtx.Done
RequestCtx.Done() now returns a channel that will be closed when
Server.Shutdown() is called.
2019-02-02 12:23:32 +01:00
Shulhan 9574c37fb8 Various changes regarding code readibility (#523)
* all: use sort.Strings when applicable

Basically, sort.Strings is the shortcut of Sort(StringSlice(a)) but its
more readable.

* all: replace string(bytes.Buffer.Bytes()) with bytes.Buffer.String()

Although its only occured on test files, it may be worth to simplified it.

* http_test: simplify strings.Index with strings.Contains

Both have the same O(n), but strings.Contains more readable on
if-condition.

* args: simplify if-condition check on boolean value

* all: simplify variable initialization

If we assign the variable after declaring it, we can simplify it using
":=" operator or "= value".
The reader can still known the type of variable from the struct name or
variable type before assignment operator.
2019-02-02 11:13:33 +00:00
Shulhan 2f22f20f02 all: fix typo on comments
While at it wrap comments with long lines.
2019-01-30 21:50:28 +01:00
Shulhan 4c53f113c5 all: pre-allocated slice with possible known size
This fix is based on suggestion of "prealloc" static analysis tool [1].

Per note of the tool's author suggestion, its recommended to allocate the
slice length/capability, if we known their possible size.  This is to
minimize "append" to re-allocate the slice underlying array.

[1] https://github.com/alexkohler/prealloc
2019-01-30 20:42:28 +01:00
Erik Dubbelboer 5de7a833de Add warning to DoTimeout 2019-01-26 22:26:59 +01:00
Erik Dubbelboer c3ff460e02 Detect 308 as redirect status code
Same as net/http does.
2019-01-19 15:13:27 +01:00
xuecai c88be72d77 add method Sort in args (#505)
* add method StringSort QueryStringSort AppendBytesSort in args

* simplify code

* only Sort method

* format

* add method StringSort QueryStringSort AppendBytesSort in args

* simplify code

* only Sort method

* format

* merge and fix tests

* change sort into generic by having the sort function

* change sort into generic by having the sort function

* change comment
v1.1.0
2019-01-04 18:38:56 +03:00
Erik Dubbelboer 9793e28938 Add test for ConnState 2019-01-03 22:23:27 +01:00
xuecai 4fb459a45e fix args empty string be changed to boolen (#502)
Add support for empty args
2018-12-30 19:56:58 +01:00
Erik Dubbelboer 2f131ba2b2 Add RequestHeader.VisitAllInOrder 2018-12-27 02:05:20 +03:00
Matt Reyer 62dcd6fdce Support SameSite cookie attribute (#488)
SameSite cookie attribute implementation.
2018-12-13 21:34:49 +06:30
Okunev Yu Dmitry caea86794c Added method (*Server).GetOpenConnectionsCount() and option DisableSleepWhenConcurrencyLimitsExceeded (#485)
* Change sleep when concurrency limits exceeded.
* Added method (*Server).GetOpenConnectionsCount()
2018-12-13 20:03:52 +06:30
Blless 1d2d99cba3 Add MaxIdemponentCallAttempts to fasthttp.Client (#484)
* Add MaxIdemponentCallAttempts to fasthttp.Client
2018-11-29 16:36:36 +06:30
Erik Dubbelboer 5836521d82 Use case-insensitive header value comparison
Fixes #483
2018-11-29 17:45:35 +08:00
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
Ciprian Dorin Craciun cd72109b02 Update server to not release read and write buffers if ReduceMemoryUsage is not set 2018-11-21 13:39:55 +06:30
Ciprian Dorin Craciun f9d5eea569 Add note about panic recovery for Server.Handler 2018-11-21 13:37:54 +06:30
Erik Dubbelboer 598a52272a No error response on keep-alive close
Don't return an error response if a keep-alive connection closes either
because the other side closed the connection or a read timeout occurs.

This will prevent net/http from printing
"Unsolicited response received on idle HTTP channel"
when a ReadTimeout is set on the fasthttp Server.

Fixes #465
2018-11-21 13:33:28 +06:30
Erik Dubbelboer 65955d6208 Don't reset headers when reading the body fails
Not doing this means people using Client can still inspect the response
headers when reading the body fails (for example when it is too big).

fixes #456
2018-11-16 00:24:33 +08:00
Erik Dubbelboer efe4585c98 Make RequestCtx implement context.Context
fixes #459
2018-11-16 00:22:29 +08:00
dgrr e9eca1e4a0 noCopy didn't implement sync.Locker well. L letter of Unlock must be lower case 2018-11-14 07:33:18 +05:30
Erik Dubbelboer 8a9bdc8177 Fix ParseUint to support all possible numbers
Fixes #461
2018-11-14 01:59:18 +08:00
Jiajun Huang 9d6d9b7cd5 fix go vet do not work on noCopy 2018-11-13 23:03:30 +05:30
Berezhnoy Pavel e771b6fe43 #457: allow to rewrite system error response (#458)
* #457: allow to rewrite system error response

* #457: review fixes

* #457: more review issues fixed
2018-11-13 15:41:42 +03:00
Erik Dubbelboer fcaab424ca Don't retry client requests with ErrBodyTooLarge
Fixes #455
2018-11-12 13:23:42 +08:00
dgrr 63a0b46e2d Changed hasNextProto name to getNextProto and deleted TODO. 2018-11-12 10:27:32 +05:30
dgrr 3fb1313e33 Changed *tls.Conn by extended connTLSer 2018-11-12 10:27:32 +05:30
dgrr d37102dec8 Fixed NextProto error caused by non-Handshake call.
As you can see here https://golang.org/src/crypto/tls/conn.go#L1041
crypto/tls.Conn does not perform a TLS handshake until Read or Write functions are called.
Then the solution is to call crypto/tls.Conn.Handshake() to check Client values.
2018-11-12 10:27:32 +05:30
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
Dmitry Yu Okunev 6b0a1c55ef Added a comment to (*Server).GetCurrentConcurrency() 2018-11-03 18:14:29 +05:30
Dmitry Yu Okunev 5684318399 Fixed race-condition of the method (*Server).GetCurrenctConcurrency() 2018-11-03 18:14:29 +05:30
Dmitry Yu Okunev 0915d6166b Added method (*Server).GetCurrenctConcurrency() 2018-11-03 18:14:29 +05:30
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
Sigalas Alexandros 1b3ac0ccc9 Fix Server.ConnState hook #441 2018-10-28 23:27:08 +05:30
Harald Nordgren f9004bedab Bump Go versions and use '.x' to always get latest minor versions 2018-10-28 23:26:41 +05:30
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 afcef43292 Add RequestCtx.Conn() method
Fixes #286
2018-10-14 10:38:42 +02:00