Commit Graph

50 Commits

Author SHA1 Message Date
Gürkan Yeşilyurt a77e9c6b79 add support for CHIPS (Cookies Having Independent Partitioned State) (#1752)
* add support for CHIPS (Cookies Having Independent Partitioned State)

* fix comment lines

* Update cookie.go fix lint error: should omit comparison to bool constant
2024-04-08 18:23:23 +02:00
Co1a 5f81476d7c feat:support zstd compress and uncompressed (#1701)
* feat:support zstd compress and uncompressed

* fix:real & stackless write using different pool to avoid get stackless.writer

* fix:zstd normalize compress level

* Change empty string checks to be more idiomatic (#1684)

* chore:lint fix and rebase with master

* chore:remove 1.18 test & upgrade compress version

* fix:error default compress level

* Fix lint

---------

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2024-02-21 07:21:52 +01:00
Erik Dubbelboer 3327266342 Follow RFCs 7230 and 9112 for HTTP versions (#1710)
Require that HTTP versions match the following pattern: HTTP/[0-9]\.[0-9]
2024-02-11 07:55:31 +01:00
AutumnSun 0d0bbfee5a Auto add 'Vary' header after compression (#1585)
* Auto add 'Vary' header after compression

Add config `SetAddVaryHeaderForCompression` to enable
'Vary: Accept-Encoding' header when compression is used.

* feat: always set the Vary header

* create and use `ResponseHeader.AddVaryBytes`

* not export 'AddVaryBytes'
2023-07-02 12:40:26 +02:00
Sergey Ponomarev 434022b461 server.go Simplify default Server name logic (#1467)
The serverName atomic.Value field is used as a cache. This is not needed and logic can be simplified.
See related #1458
2023-01-06 04:55:09 +01:00
Sergey Ponomarev 51048b0620 client.go Simplify default UA logic (#1466)
The getClientName() checks if !NoDefaultUserAgentHeader then returns the Client.Name field.
But it also saves it to atomic field clientName. This is not needed and logic can be simplified.
Previously the clientName vas a byte slice that was copied from c.Name and cached. See 02e0722fb7

Fix #1458
2023-01-02 12:51:39 +08:00
Erik Dubbelboer 6b5bc7bb30 Add windows support to normalizePath
This is probably still not 100% sure and there are still many bugs with
FS on windows. But it's a slight improvement.

Fixes #1226
2022-02-28 11:56:59 +01:00
ichx da7ff7a208 Add trailer support (#1165)
* Add trailer support

* fix issue and add documentation

* remove redundant code

* add error return for add/set trailer method

* fix lint error

* fix bad trailer error return issue and update bad content-length error

* update errNonNumericChars

* update errNonNumericChars

* fix issue about error and fix typo
2021-12-05 14:11:51 +01:00
Erik Dubbelboer 46d92356a8 Check go fmt during lint (#1097) 2021-09-10 18:49:45 +02:00
Kyle Unverferth 713da4e33f Adding new compressible prefixes (#1092)
* Adding "image/svg" as compressible prefix

* Adding additional compressible prefixes from https://support.cloudflare.com/hc/en-us/articles/200168396-What-will-Cloudflare-compress-
2021-09-07 10:03:41 +02:00
tyltr f0a21893b9 feat: improve IsMethod (#1088)
* feat: improve bytesEqual

* benchmark

* nolint:unused

* remove unused  code

* Update client.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2021-09-06 12:06:21 +02:00
MoreFreeze ffa0cabed8 Use proper content-type when it is not present (#1023)
Co-authored-by: liuchenxing <liuchenxing@bytedance.com>
2021-05-17 09:20:18 +02:00
Mike Faraponov a5830066b6 Use bytes.IndexByte instead of bytes.Index for single byte lookup (#999)
* Update uri.go

* Update strings.go
2021-03-20 15:57:57 +01:00
Darío 1b61ca2e36 Added Protocol() as a replacement of hardcoded strHTTP11 (#969)
* Added Protocol() as a replacement of hardcoded strHTTP11

* Applied review changes

* Modify h.proto in parseFirstLine
2021-02-16 21:53:40 +01:00
Erik Dubbelboer 339ad36634 Add Brotli support
New Functions:

    CompressHandlerBrotliLevel(h RequestHandler, brotliLevel, otherLevel int) RequestHandler
    Request.BodyUnbrotli() ([]byte, error)
    Response.BodyUnbrotli() ([]byte, error)
    AppendBrotliBytesLevel(dst, src []byte, level int) []byte
    WriteBrotliLevel(w io.Writer, p []byte, level int) (int, error)
    WriteBrotli(w io.Writer, p []byte) (int, error)
    AppendBrotliBytes(dst, src []byte) []byte
    WriteUnbrotli(w io.Writer, p []byte) (int, error)
    AppendUnbrotliBytes(dst, src []byte) ([]byte, error)

New Constants:

    CompressBrotliNoCompression
    CompressBrotliBestSpeed
    CompressBrotliBestCompression
    CompressBrotliDefaultCompression

Brotli compression levels are different from gzip/flate. Because of this we have separate level constants and CompressHandlerBrotliLevel takes 2 levels.

I didn't add Brotli support to CompressHandler as this could cause a spike in CPU usage when users upgrade fasthttp.

fasthttp.CompressBrotliDefaultCompression is not the same as
brotli.DefaultCompression. brotli.DefaultCompression is more than twice
as slow as fasthttp.CompressBrotliDefaultCompression which I thought was
unreasonable as default.
2020-05-15 15:36:26 +02:00
Erik Dubbelboer 1d6a7e0493 The Authorization header should include the Basic keyword
Thanks to https://github.com/paween1980
2019-09-27 17:29:44 +02:00
Erik Dubbelboer 2edabf3b76 Add support for user:pass in URLs (#614)
Fixes #609
2019-08-18 11:23:33 +02:00
Rem 9ba4cef1ba Support SameSite value "None" cookie attribute (#581)
* Support SameSite value "None" cookie attribute

* Fix typo in CookieSameSiteNoneMode comment

* fix comment for SameSite None
2019-06-14 16:07:33 +02:00
Maxim Lebedev d3715c361c Used Headers constants instead raw strings 2019-05-28 18:04:24 +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
Erik Dubbelboer 6647cb2885 Remove duplicate check
We already compare headers case insensitive so we don't need to compare
two different cases.
2019-02-09 11:29:47 +01:00
Matt Reyer 62dcd6fdce Support SameSite cookie attribute (#488)
SameSite cookie attribute implementation.
2018-12-13 21:34:49 +06:30
David Byttow dbc9965d33 Adds support for max-age cookie value. Fixes #184 (#412)
Adds support for max-age cookie value
2018-09-13 12:19:38 +08: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 b154429ca9 Compress responses only if their content-type starts with text/ or application/ 2017-05-17 17:10:29 +03:00
Tracer Tong ae8de36df0 Issue #107 (#108) 2016-05-27 18:54:11 +03:00
Aliaksandr Valialkin 1498d8174e Issue #73: added 'HttpOnly' and 'secure' flags support to Cookie 2016-03-29 16:12:59 +03:00
Aliaksandr Valialkin 8a83396595 FS: added support for byte range requests 2016-01-05 14:05:07 +02:00
Aliaksandr Valialkin 4bca54c0bb Issue #29: use time.UTC instead of time.LoadLocation, since this call may fail on systems without certain config files 2016-01-04 15:55:30 +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 149f0f38b7 Issue #14: added CompressHandler wrapper for transparent response compression support 2015-12-25 13:33:01 +02:00
Aliaksandr Valialkin edcfdbcec9 Issue #14: added support for response body compression 2015-12-25 12:26:34 +02:00
Aliaksandr Valialkin 032414c0ac Use utf-8 charset in defaultContentType 2015-12-16 21:17:16 +02:00
Aliaksandr Valialkin 495e130b8f Issue #16: support 'Connection: keep-alive' header for non-http/1.1 requests and/or responses 2015-12-10 11:19:34 +02:00
Aliaksandr Valialkin 9c18f79145 Added support for If-Modified-Since to SendFile and FS 2015-12-09 18:51:51 +02:00
Aliaksandr Valialkin ed1d21e27d Remove '/./' parts from path 2015-12-03 19:00:24 +02:00
Aliaksandr Valialkin 6a340b7334 Added request PUT method support 2015-11-29 11:32:44 +02:00
Aliaksandr Valialkin 8563a2e762 Follow redirects in client Get* and Post* methods. Added Redirect method to RequestCtx. 2015-11-28 14:47:19 +02:00
Aliaksandr Valialkin 01031f43e2 Added support form multipart/form-data POST requests 2015-11-27 16:23:02 +02:00
Aliaksandr Valialkin 0c6b0a01a1 Shorten default server and client names 2015-11-25 13:46:19 +02:00
Aliaksandr Valialkin 52c04f13b2 Added support for 'Connection: Upgrade', so RequestHandler may detect such connections and hijack them 2015-11-24 15:48:10 +02:00
Aliaksandr Valialkin ed68dfc5f6 Optimization: do not parse full requests headers on ConnectionClose and Header calls. This should speed up common case with GET requests on the server 2015-11-19 12:15:20 +02:00
Aliaksandr Valialkin 7bffd9aed5 removed charset=utf-8 from default content-type, since it is implied by default 2015-11-19 11:49:12 +02:00
Aliaksandr Valialkin 63aab18752 do not optimize for content-length access on response headers, since it works slower than full headers parsing 2015-11-17 11:10:52 +02:00
Aliaksandr Valialkin f1e8e6bf25 Added support for identity responses. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 for details 2015-11-13 13:33:32 +02:00
Aliaksandr Valialkin b81ce4977b Added https support to client 2015-11-12 21:42:16 +02:00
Aliaksandr Valialkin 4c2a55ed12 Set default user-agent in http request 2015-11-08 21:58:46 +02:00
Aliaksandr Valialkin 87105b99cb Added response cookies support 2015-11-05 12:07:54 +02:00
Aliaksandr Valialkin 4123c87e7c Initial support of request cookies 2015-11-03 19:08:34 +02:00
Aliaksandr Valialkin 0d9bc5cfde Extracted predefined strings into a separate file 2015-11-03 17:48:44 +02:00