Xu Qiaolun
ecb7cbdfb2
call the ConnState callbacks in Server.ServeConn
2018-08-30 15:20:32 +00:00
Xu Qiaolun
c88d0992b4
vendor ConnState type in fasthttp package
2018-08-30 15:20:32 +00:00
徐乔伦
69613e6feb
add support for http.ConnState
...
issue #205
2018-08-30 15:20:32 +00:00
Erik Dubbelboer
7c74b1f431
Remove duplicate check
...
Is already checked at https://github.com/valyala/fasthttp/blob/4a16377d6e780cb75b91962ea2100d83f7452565/http.go#L1190
and https://github.com/valyala/fasthttp/blob/4a16377d6e780cb75b91962ea2100d83f7452565/http.go#L1244
2018-08-27 21:46:12 +00:00
Erik Dubbelboer
d689bfcde7
Copy file if rename fails (save multipart)
...
Renaming a file can fail when the two files are on different devices.
Just copy if rename fails for any reason. If rename fails because of
other reaons copy will either work or fail for the same reason as well
so we won't miss any errors after this.
2018-08-27 21:35:30 +00:00
Erik Dubbelboer
5b46f8ddc5
Added support for multiple TLS domains
...
See: https://github.com/erikdubbelboer/fasthttp/pull/24
2018-08-25 20:11:58 +03:00
Erik Dubbelboer
d84d8ea604
Allow removal of the Server header in responses
...
his PR adds an option to the Server called `NoDefaultServerHeader` that
allows a user to indicate that neither the Server's `Name` field nor
the `defaultServerName` should be included in the Server's responses
as a `Server` header by default.
Now when `ResponseHeader.AppendBytes` is found to have an empty `server`
field, it simply skips the `Server` header. Previously that method
would write the `defaultServerName` when no value was found. The only
code paths that took advantage of that were ones originating from
`writeErrorResponse`, which now handles setting the server name
directly.
Fixes: https://github.com/valyala/fasthttp/issues/221
2018-08-25 16:00:48 +03:00
Erik Dubbelboer
e3d61d58fd
Add Server.Shutdown
2018-08-25 01:39:00 +03:00
Erik Dubbelboer
cf6f6e7fca
Read GET/HEAD body if it exists
...
Previously, GET/HEAD bodies were not read. The HTTP 1.1 specification
states:
"A server SHOULD read and forward a message-body on any request; if the
request method does not include defined semantics for an entity-body,
then the message-body SHOULD be ignored when handling the request.
I suspect this code is at fault."
This change reads the body on such request and continues the previous
behavior of returning a "Content-Length" of 0 to the application.
See: https://github.com/valyala/fasthttp/issues/159
2018-08-24 16:21:17 +03:00
Erik Dubbelboer
3f904e1492
Remove code that does nothing
...
connTime never changes so the statement does nothing.
2018-08-24 15:50:31 +03:00
Erik Dubbelboer
a58298a3a8
Fix doc for some time functions
...
They still said the return value would be truncated to the nearest
second which is false after ef10ed05a3 .
2018-08-21 17:58:36 +03:00
Kirill Danshin
ef10ed05a3
deprecate CoarseTime and replace it with a shortcut implementation
...
Signed-off-by: Kirill Danshin <k@guava.by >
2018-08-17 18:12:21 +03:00
Kirill Danshin
4c7269ec2a
Revert "Remove CoarseTime"
...
This reverts commit f2ddaffc31 .
2018-08-17 15:32:15 +03:00
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