Commit Graph

78 Commits

Author SHA1 Message Date
Maxim Lebedev d3715c361c Used Headers constants instead raw strings 2019-05-28 18:04:24 +03:00
Vladimir Shteinman 74ad0f8e9b Export struct var and add specs 2019-05-22 23:23:02 +03:00
Maxim Lebedev f544170d63 Added methods constants (#567)
*  Added methods constants

* 👌 Fixed methods comment due to review changes
2019-05-06 17:54:49 +02:00
Ciprian Dorin Craciun 733a6505a9 Support huge read-only []byte response bodies (#477)
* Add `Response.SetBodyRaw` method that serves a `[]byte` slice without touching it  (as an alternative to `SetBody`)
* Update various response related functions that are impacted after the incoduction of `Response.bodyRaw`
* Add a few test-cases in relation to `Response.SetBodyRaw`
2019-02-24 08:32:54 +00:00
xuecai ed3793a1e1 add tests for copyto (#545)
* add tests for copyto
* add HeaderCopy Test reflect.DeepEqual
2019-02-17 10:11:45 +00: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
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
Erik Dubbelboer 192515395f Add Client.NoDefaultUserAgentHeader 2018-11-01 12:44:17 +08:00
Tommy Chen d459e257bf Use form headers in WriteMultipartForm
CreateFormFile always set Content-Type header to application/octet-stream.
Use CreatePart instead so all headers in the multipart form can be used.
2018-10-05 19:02:16 +03:00
Erik Dubbelboer d4f0cf56d8 Remove fasthttp.ByteBuffer
As advertised in https://github.com/valyala/fasthttp/commit/b5f96d4b4120bb1e09c23ac32baf21a14da4a71d
2018-10-01 14:15:29 +08:00
Erik Dubbelboer 26aa8e51e8 Allow whitespace after chunk size
There seems to be servers/load balancers that insert whitespaces
between the chunk-size number and \r\n.
2018-08-27 21:42:46 +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
Aliaksandr Valialkin 498431ce67 Added missing bufio.Writer.Flush() in testResponseBodyStream* 2017-06-28 18:18:09 +03:00
Aliaksandr Valialkin 8948e047bf Issue #176: reset Content-Length when compression is enabled for streamed response body 2017-06-27 20:50:04 +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
Aliaksandr Valialkin 103adc311e Do not compress responses with sizes smaller than 200 bytes
Compressing small bodies has little sense, since the compressed result size
may exceed the original body size.

This should save CPU time when the server responds with small responses.
2017-05-17 16:17:53 +03:00
Aliaksandr Valialkin 4ee6517626 Issue #193: properly handle nil body when calling WriteGzip* and WriteDeflate* on Response struct 2016-10-31 13:41:50 +02:00
Aliaksandr Valialkin 3e1cb31dcd Added SwapBody to Request and Response for zero-copy body pass between Request and Response objects 2016-09-12 13:42:59 +03:00
Aliaksandr Valialkin 834fb48f10 Immediately write compressed response data to the connection after the user flushes the data from StreamWriter 2016-08-18 13:03:57 +03:00
Aliaksandr Valialkin d055141f64 Propagate 'https' scheme to request URI for TLS connections 2016-08-17 14:01:35 +03:00
Aliaksandr Valialkin 83a24c301b Issue #114: added SetHost and Host helper methods to Request 2016-06-15 20:32:54 +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
Aliaksandr Valialkin fa50251b46 Issue #100: accept POST query args with arbitrary charset set via Content-Type 2016-05-20 18:14:06 +03:00
Aliaksandr Valialkin bfa17b7ae9 do not copy Request and Cookie objects in tests 2016-03-28 17:17:05 +03:00
Aliaksandr Valialkin 877a47395f Issue #61: use proper content-length in multipart/form-data tests 2016-03-01 18:12:00 +02:00
Aliaksandr Valialkin 31a9d3461e Issue #61: test request with multipart/form-data body containing file value 2016-03-01 17:13:49 +02:00
Aliaksandr Valialkin b98beaa40f Added RequestURI helper to Request 2016-02-21 13:22:13 +02:00
Aliaksandr Valialkin be49d3027a Allow updating request's RequestURI and Host header via Request.URI() 2016-02-19 18:53:13 +02:00
Aliaksandr Valialkin e7e436064f Keep response and request body after calling Body() if SetBodyStream is called 2016-02-13 11:42:22 +02:00
Aliaksandr Valialkin 77a12cbf68 Added SetBodyStream* to Request. This allows streaming multi-GB data in request bodies 2016-02-12 20:52:29 +02:00
Aliaksandr Valialkin bfce0fa31c substituted bytes.Buffer by ByteBuffer in tests where appropriate 2016-02-12 14:15:28 +02:00
Aliaksandr Valialkin 6cd79f25f2 Added BodyWriteTo to Request and Response 2016-02-09 20:04:46 +02:00
Aliaksandr Valialkin 0458fee5cd Issue #15: make sure that io.EOF isn't returned on incomplete request/response 2016-02-05 13:22:03 +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 f8c0d95e57 Issue #40: added io.WriterTo implementation to Request and Response 2016-01-21 12:24:51 +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 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 c5d9023043 Issue #30: properly handle content-length for HEAD responses 2016-01-05 18:02:50 +02:00
Aliaksandr Valialkin dbe26b3541 Do not set Content-Length in GET and HEAD requests according to pull request #31 (thanks to @buaazp ) 2016-01-05 15:47:30 +02:00
Aliaksandr Valialkin f704d819f6 Always return multipart form body on Request.Body() call 2015-12-31 15:38:34 +02:00
Aliaksandr Valialkin 51460d7747 Fixed a typo 2015-12-31 12:10:48 +02:00
Aliaksandr Valialkin 5700ef75d0 Added a test for reading gzipped request body according to @celer's email 2015-12-31 12:10:12 +02:00
Aliaksandr Valialkin 85ae42bdba Do not read request body if both 'Content-Length' and 'Transfer-Encoding' headers are missing. Based on @celer's patch at https://github.com/celer/fasthttp/commit/667a8905cc6a95f223b5bd41056b1ea2861118df 2015-12-31 11:12:41 +02:00
Aliaksandr Valialkin 3284c3e671 Pull request #24: added support for '100 Continue' responses and 'Expect: 100-continue' requests. Kudos to @celer 2015-12-25 16:11:20 +02:00
Aliaksandr Valialkin edcfdbcec9 Issue #14: added support for response body compression 2015-12-25 12:26:34 +02:00
Aliaksandr Valialkin e4c3007338 Improved RequestCtx.WriteString() test 2015-12-24 20:54:17 +02:00
Aliaksandr Valialkin 80105c1a85 Added RequestCtx.WriteString 2015-12-24 20:48:05 +02:00
Aliaksandr Valialkin 6a340b7334 Added request PUT method support 2015-11-29 11:32:44 +02:00
Aliaksandr Valialkin 01031f43e2 Added support form multipart/form-data POST requests 2015-11-27 16:23:02 +02:00
Aliaksandr Valialkin df6fda8c33 Added ability to limit request body size on the server and response body size on the client 2015-11-27 13:22:15 +02:00