Erik Dubbelboer
f2ddaffc31
Remove CoarseTime
...
It is not clear why @valyala introduced this coarse time. Benchmarks on
different systems show that the speedup is no where enough to justify
the added code complexity and bugs it seems to have introduced.
Mac:
BenchmarkCoarseTimeNow-8 2000000000 2.49 ns/op
0 B/op 0 allocs/op
BenchmarkTimeNow-8 500000000 3.14 ns/op
0 B/op 0 allocs/op
Ubuntu:
BenchmarkCoarseTimeNow-4 300000000 6.74 ns/op
0 B/op 0 allocs/op
BenchmarkTimeNow-4 100000000 15.9 ns/op
0 B/op 0 allocs/op
This reverts commit https://github.com/erikdubbelboer/fasthttp/commit/6309f42188ecb28ccf8ac58442739cdb43d75d9e
and https://github.com/erikdubbelboer/fasthttp/commit/32c72cde80f0c591604f825586d6a4bbbb39d9c5 .
See: https://github.com/valyala/fasthttp/issues/271 ,
https://github.com/valyala/fasthttp/pull/269 and
https://github.com/valyala/fasthttp/issues/261 .
2018-08-17 17:15:41 +08:00
Kirill Danshin
4a16377d6e
Merge pull request #303 from chebyrash/master
...
Typo fixes
2018-08-13 23:18:55 +03:00
toyblocks
a84dc2dc0e
Add missing http methods
...
Add support for 'CONNECT', 'OPTIONS', 'TRACE' and 'PATCH'
2018-03-12 07:00:21 +09:00
Aliaksandr Valialkin
70ceaddfae
Added RequestCtx.String that returns unique string representation of the request context
2017-10-18 15:53:05 +03:00
xPushkin
f24d00fcc6
A lot of typo fixes
2017-10-08 13:30:35 +01:00
Aliaksandr Valialkin
30e92af08f
Limit heap memory usage when compressing high number of concurrent responses
...
Previously each concurrent compression could allocate huge compression state
with the size up to 1Mb each. So 10K concurrent connections could result in
10Gb of compression state in the heap.
This CL limits the number of compression states among concurrent requests
when {Append,Write}{Gzip,Deflate}* functions are called to O(GOMAXPROCS).
These functions are used by CompressHandler* for non-streaming responses,
i.e. it should cover the majority of use cases.
Memory usage for 10K concurrent connections that compress responses drops
from 10Gb to 200Mb after this CL.
2017-05-17 14:45:31 +03:00
Aliaksandr Valialkin
f06438ae94
doc: mention that RequestCtx.ConnRequestNum() returns connection request numbers starting from 1
2017-02-20 16:00:55 +02:00
Aliaksandr Valialkin
32c72cde80
Export CoarseTimeNow and clarify that RequestCtx.Time() and RequestCtx.ConnTime() return time truncated to a second
2017-02-10 15:45:14 +02:00
Aliaksandr Valialkin
6309f42188
optimization: substitute time.Now() calls with coarse-grained time in hot paths
2017-02-09 23:59:06 +02:00
Aliaksandr Valialkin
b0de56d13b
Properly set "https" scheme in RequestCtx.URI() for TLS connections
2017-01-15 00:26:21 +02:00
Aliaksandr Valialkin
82894ea1e8
Added RequestCtx.LocalIP()
2016-12-14 13:51:36 +02:00
Aliaksandr Valialkin
1913bdea45
Set 'Connection: close' response header when server couldn't parse or accept incoming request
2016-11-17 13:50:15 +02:00
Aliaksandr Valialkin
02fe9b8533
Issue #173 : return valid response instead of silently closing connection on request parsing errors
2016-11-10 18:09:23 +02:00
Aliaksandr Valialkin
cd7c1dafbc
Properly handle TimeoutHandler in custom server implementations, which use RequestCtx.Init* functions
2016-10-21 15:39:05 +03:00
Aliaksandr Valialkin
935c556b36
Added RequestCtx.Hijacked method for determining whether the underlying connection is hijacked
2016-10-21 14:33:22 +03:00
Aliaksandr Valialkin
e0c9f3d5ff
typo fixes in comments
2016-10-13 17:39:06 +03:00
Aliaksandr Valialkin
d03a227209
Added reduceMemoryUsage argument to RequestCtx.Init2 - it is required for httpteleport
2016-09-23 12:10:21 +03:00
Aliaksandr Valialkin
ec59ce31a6
Added RequestCtx.Init2 function for the upcoming httpteleport project
2016-09-20 20:43:25 +03:00
Aliaksandr Valialkin
5210f60181
Detect overriden TLS connections in RequestCtx.IsTLS and RequestCtx.TLSConnectionState
2016-08-17 18:01:59 +03:00
Aliaksandr Valialkin
d055141f64
Propagate 'https' scheme to request URI for TLS connections
2016-08-17 14:01:35 +03:00
Aliaksandr Valialkin
45915c69f6
Optimization: recycle request and response body buffers only if Server.ReduceMemoryUsage is set
2016-07-18 17:46:52 +03:00
Aliaksandr Valialkin
a2cc660e59
optimization: removed slow defer from worker pool handler and hijack handler
2016-07-18 17:23:38 +03:00
Aliaksandr Valialkin
886e541160
Removed 'recover-from-panic' band-aids.
...
All the panics must be handled by the user code.
2016-07-12 12:30:38 +03:00
Gerasimos Maropoulos
006fac3cba
Implement VisitUserValues - https://github.com/valyala/fasthttp/issues/126 ( #129 )
2016-07-12 09:40:24 +03:00
Aliaksandr Valialkin
e4db3cb560
Security fix: limit request body size by default
...
This mitigates possible DoS-attacks based on sending very BIG request bodies
to the server with default settings.
Thanks to @MichaelMonashev for pointing to this attack.
2016-06-28 20:54:42 +03:00
Aliaksandr Valialkin
d42167fd04
Set response Server header to Server.Name if it is empty. This properly handles #118
2016-06-17 13:13:04 +03:00
Alexander Shchepetilnikov
e2fcfbaea5
Fix typo ( #115 )
2016-06-13 17:58:03 +03:00
Aliaksandr Valialkin
3c5ba2c98d
Limit the number of concurrently running request handlers inside TimeoutHandler
2016-06-06 16:47:02 +03:00
Aliaksandr Valialkin
b8b31526d7
Do not compress already compressed response in CompressHandler
2016-06-06 14:15:34 +03:00
Aliaksandr Valialkin
90baa054bc
Export IsBodyStream on RequestCtx, Request and Response
...
These methods may help writing proper request handler wrappers
for request handlers, which may set body either via SetBodyStream*
or via usual body methods.
2016-06-03 17:07:13 +03:00
Tracer Tong
ae8de36df0
Issue #107 ( #108 )
2016-05-27 18:54:11 +03:00
Aliaksandr Valialkin
cefa3b1f52
Issue #105 : listen by default only on IPv4, since IPv6 may be misleading / unexpected / buggy
2016-05-27 16:53:10 +03:00
Aliaksandr Valialkin
f68634569e
Issue #103 : Set 'Server' response header before calling user-provided request handler
2016-05-24 15:41:08 +03:00
Aliaksandr Valialkin
2d5c6fd01a
Added Server.ConnID() for associating distinct requests that come from the same client connection
2016-04-24 22:01:13 +03:00
Aliaksandr Valialkin
2296988764
server: prefer server ciphers for TLS. This improves server rating on https://www.ssllabs.com/ssltest/analyze.html
2016-04-19 12:30:49 +03:00
Aliaksandr Valialkin
5fdbeef505
Server optimization: reduce the number of SetReadDeadline/SetWriteDeadline calls for keep-alive connections, since they don't scale properly. See https://github.com/golang/go/issues/15133 for details
2016-04-15 13:47:44 +03:00
Aliaksandr Valialkin
8d147e45af
Issue #76 : fixed data races in TimeoutHandler and RequestCtx.TimeoutError*. Updated tests for catching similar data races in the future
2016-04-06 15:08:34 +03:00
Aliaksandr Valialkin
65540104b3
server: verify request's 'Connection: close' after request handler returns
2016-03-31 10:17:29 +03:00
Aliaksandr Valialkin
7d29fb3b3d
server: added DisableKeepalive option for disabling keep-alive connections
2016-03-31 10:05:31 +03:00
Aliaksandr Valialkin
92c779039c
workerpool: clean workerChan slices in order to reduce the amount of work for GC
2016-03-30 18:11:40 +03:00
Aliaksandr Valialkin
0d43464f64
Renamed unsafeBytes2Str to b2s
2016-03-29 16:26:21 +03:00
Aliaksandr Valialkin
169b5eac74
server: sleep for a while after reaching the concurrency limit, so other concurrently running servers could accept and process incoming connections
2016-03-29 12:00:21 +03:00
Aliaksandr Valialkin
d444ab9169
Server: write error response when concurrency limit or per-ip conn limit is exceeded before closing the connection. This should improve server diagnostics
2016-03-28 18:42:40 +03:00
Aliaksandr Valialkin
8280b7a162
Moved empty noCopy struct to the top of container structs. See @stemar94 's comment at https://github.com/golang/go/issues/12884 for details
2016-03-06 00:17:08 +02:00
Aliaksandr Valialkin
9f43aa1601
Do not expose noCopy.Lock
2016-03-04 21:20:52 +02:00
Aliaksandr Valialkin
9fa69c74af
Embed noCopy struct into structs, which mustn't be copied
...
This should help `go vet` detecting invalid structs' copyings.
See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details.
2016-03-04 16:57:24 +02:00
Aliaksandr Valialkin
15ffe2f795
Issue #63 : added helper functions for starting https server with certificates embedded into the app
2016-03-02 15:23:21 +02:00
Aliaksandr Valialkin
68c6a4f496
Added ServeFileBytes* and RequestCtx.SendFileBytes* helper functions
2016-02-29 14:42:55 +02:00
Aliaksandr Valialkin
dd6954f4b2
Issue #57 : Server: added ability to disable header names' normalizing
2016-02-25 14:00:04 +02:00
Aliaksandr Valialkin
108d002365
Added tests for Server.ReduceMemoryUsage flag
2016-02-24 15:45:56 +02:00