Erik Dubbelboer
b174f54b12
Add method to get cookie from response
2018-08-27 21:46:32 +00:00
Erik Dubbelboer
e277e51b15
Add support for ResponseHeader.Peek("Set-Cookie")
...
See: https://github.com/erikdubbelboer/fasthttp/issues/4
2018-08-27 21:42:16 +00: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
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
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
xPushkin
f24d00fcc6
A lot of typo fixes
2017-10-08 13:30:35 +01:00
Aliaksandr Valialkin
52a0993b96
Issue #278 : more optimizations for normalizeHeaderKey
2017-07-11 10:17:57 +03:00
Aliaksandr Valialkin
952171f61b
Issue #278 : optimize normalizeHeaderKey a bit
...
Performance results on amd64:
name old time/op new time/op delta
NormalizeHeaderKeyCommonCase-4 43.3ns ± 0% 32.6ns ± 1% -24.80% (p=0.000 n=9+10)
NormalizeHeaderKeyLowercase-4 42.6ns ± 3% 32.6ns ± 1% -23.41% (p=0.000 n=10+10)
NormalizeHeaderKeyUppercase-4 43.5ns ± 1% 32.6ns ± 2% -25.03% (p=0.000 n=9+8)
Based on top of https://github.com/valyala/fasthttp/pull/279 .
2017-07-10 14:28:06 +03:00
Aliaksandr Valialkin
b154429ca9
Compress responses only if their content-type starts with text/ or application/
2017-05-17 17:10:29 +03:00
Perelandric
3580c93d02
Make SetMethod slice to zero before appending ( #234 )
...
SetMethod appended directly to the `h.method` slice without setting its
length to zero, so multiple calls would create an unexpected value.
2017-02-22 09:48:29 +02:00
Aliaksandr Valialkin
2ada93a6df
Document that the cookie passed to ResponseHeader.SetCookie may be re-used after the function returns
2017-01-18 19:20:47 +02:00
Aliaksandr Valialkin
ef299a95e2
Fixed TestServerErrSmallBuffer for go 1.6
2016-11-14 23:16:56 +02:00
Aliaksandr Valialkin
3246b4efb5
Issue #173 : improve error messages on headers parsing
2016-11-10 20:00:54 +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
Clayton Anderson
1909d6a025
Fixed bug with quoted multipart form boundaries ( #135 )
2016-07-12 09:33:29 +03:00
Aliaksandr Valialkin
15c8282c3f
typo fix
2016-06-27 17:52:45 +03:00
Aliaksandr Valialkin
80e08dc9ef
Cross-reference Set* with Add* methods on RequestHeader and ResponseHeader
2016-06-27 17:48:32 +03:00
Aliaksandr Valialkin
661978870b
return StatusOK from an empty ResponseHeader.StatusCode()
2016-06-06 14:08:53 +03:00
Tracer Tong
ae8de36df0
Issue #107 ( #108 )
2016-05-27 18:54:11 +03:00
Aliaksandr Valialkin
3509bd8a7d
Issue #83 : Added ResponseHeader.DelClientCookie for instructing the client for removing the given cookie. Clarified ResponseHeader.DelCookie documentations
2016-04-29 14:40:55 +03:00
Aliaksandr Valialkin
2a12271406
Issue #83 : Added DelCookie* methods to RequestHeader and ResponseHeader
2016-04-24 22:34:33 +03:00
Aliaksandr Valialkin
12ba989984
Issue #69 : Added RequestHeader.Add and ResponseHeader.Add for adding multiple headers with the same key
2016-03-29 17:11:43 +03:00
Aliaksandr Valialkin
0c67179812
Added delAllArgsBytes helper
2016-03-29 16:30:07 +03:00
Aliaksandr Valialkin
0d43464f64
Renamed unsafeBytes2Str to b2s
2016-03-29 16:26:21 +03:00
Aliaksandr Valialkin
8b26017325
Renamed setArg to setArgBytes
2016-03-29 16:19:22 +03:00
Aliaksandr Valialkin
c469d18819
Issue #72 : properly handle 'Connection: keep-alive, Upgrade' header
2016-03-22 19:47:59 +02:00
Aliaksandr Valialkin
ca2c5535a3
do not write 'date' response header, since 'date' header is automatically generated
2016-03-11 11:05:32 +02:00
Aliaksandr Valialkin
e0eac18652
use 'switch string(key) {}' instead of 'switch { case bytes.Equal(key, ...) ... }'. This may improve switch statement's performance
2016-03-10 17:44:58 +02:00
Aliaksandr Valialkin
38356e216e
Issue #64 : properly delete header values via Del call
2016-03-10 17:22:59 +02: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
ad8f9d1f6f
Issue #57 : Exported AppendNormalizedHeaderKey
2016-02-25 21:28:13 +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
714b45e4c7
Print only the first 200 and the last 200 bytes of the buffer on error during headers' reading
2016-02-18 15:57:34 +02:00
Aliaksandr Valialkin
320182f734
Return more clear error message when headers don't fit read buffer size
2016-02-18 15:33:30 +02:00
Aliaksandr Valialkin
fd2887a5fc
Issue #53 : Clarify that the following instances mustn't be used from concurrently running goroutines: Args, Cookie, URI, RequestCtx, Request, Response, RequestHeader and ResponseHeader
2016-02-17 11:45:21 +02:00
Aliaksandr Valialkin
445fb8a9ae
header: skip trailing CRLFs after request/response bodies
2016-02-16 19:37:51 +02:00
Aliaksandr Valialkin
52d4b7ca38
Issue #15 : document that io.EOF is returned from Read* calls on (Request|Response)(Header)? only if the reader is closed before the first byte read
2016-02-05 13:14:36 +02:00
Aliaksandr Valialkin
52ddf98cfd
Fixed golint warnings
2016-01-19 12:43:23 +02:00
Aliaksandr Valialkin
a208149ac4
FS optimization: do not read file contents on HEAD requests
2016-01-18 20:40:43 +02:00
Aliaksandr Valialkin
81b5321d14
Removed misleading ConnectionCloseReal method from RequestHeader
2016-01-17 00:43:34 +02:00
Sebastian Schepens
fa88c5b853
Don't assume Content-Encoding: identity when request is 1xx, 204 or 304
2016-01-12 15:23:14 -03:00
Aliaksandr Valialkin
3bd3552062
Added ResetConnectionClose() to RequestHeader and ResponseHeader
2016-01-08 13:43:44 +02:00
Aliaksandr Valialkin
7d7c17c8d7
Do not send response body (and content-length) for 1xx, 204 and 304 responses
2016-01-06 15:22:52 +02:00
Aliaksandr Valialkin
2ff945b9ea
Properly reset scratch buffer for header values
2016-01-05 14:30:05 +02:00
Aliaksandr Valialkin
8a83396595
FS: added support for byte range requests
2016-01-05 14:05:07 +02:00
Aliaksandr Valialkin
69a05ffcaf
Issue #28 : do not set default Content-Type for empty response
2016-01-04 14:56:49 +02:00
Aliaksandr Valialkin
e5d7485342
truncate raw headers buffer before passing to readRawHeaders
2015-12-31 15:37:41 +02:00