aboutsummaryrefslogtreecommitdiff
path: root/header_test.go
AgeCommit message (Collapse)AuthorFilesLines
2024-03-02Enable perfsprint linter; fix up lint issues (#1727)Gravatar Oleksandr Redko 1-3/+4
2024-03-02test: remove `//nolint:govet` comments (#1729)Gravatar Oleksandr Redko 1-6/+6
2024-02-21Upgrade golangci-lint to v1.56.2; fix gocritic issues (#1722)Gravatar Oleksandr Redko 1-7/+7
2024-02-11Prevent request smuggling (#1719)v1.52.0Gravatar Erik Dubbelboer 1-4/+9
* Prevent request smuggling Prevent request smuggling when fasthttp is behind a reverse proxy that might interprets headers differently by being stricter. Should also prevent request smuggling when fasthttp is used as the reverse proxy. * Make header value comparison case-insensitive
2024-02-11Follow RFCs 7230 and 9112 for HTTP versions (#1710)Gravatar Erik Dubbelboer 1-9/+5
Require that HTTP versions match the following pattern: HTTP/[0-9]\.[0-9]
2024-01-09Move Fuzz tests into their own fileGravatar Erik Dubbelboer 1-20/+0
This is required for https://github.com/google/oss-fuzz/pull/11453
2024-01-04Change empty string checks to be more idiomatic (#1684)Gravatar Oleksandr Redko 1-1/+1
2024-01-02feat: add function to parse HTTP header parameters (#1685)Gravatar nickajacks1 1-0/+69
* feat: add function to parse HTTP header parameters The implementation is based on RFC-9110 5.6.6. * test: add fuzz for VisitHeaderParams
2023-08-30docs: fix typos in comments and testsGravatar Oleksandr Redko 1-3/+3
2023-08-29Enable gocritic linter; fix lint issues (#1612)Gravatar Oleksandr Redko 1-8/+4
2023-07-06Avoid nolint:errcheck in header tests (#1589)Gravatar Oleksandr Redko 1-7/+19
2023-07-02Auto add 'Vary' header after compression (#1585)Gravatar AutumnSun 1-0/+62
* 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-06-13Enable gofumpt linter; format code `gofumpt -w .` (#1576)v1.48.0Gravatar Oleksandr Redko 1-6/+7
2023-06-12add DisableSpecialHeaders option (#1573)Gravatar Anthony Ter-Saakov 1-0/+29
* add DisableSpecialHeaders option * polishing up disableSpecialHeader option * forgot to uncomment * fix silly mistakes * dont parse special headers
2023-04-14fix: add noDefaultContentType copy (#1538)Gravatar kinggo 1-0/+1
2023-03-06test: fix typos in function, error message, comment (#1512)Gravatar Oleksandr Redko 1-2/+2
2023-02-15test: close response body (#1496)Gravatar Oleksandr Redko 1-0/+1
2023-02-11docs: replace links to golang.org with go.dev (#1489)Gravatar Oleksandr Redko 1-1/+1
- Replace https://godoc.org with https://pkg.go.dev. - Replace https://golang.org with https://go.dev. - Replace https://golang.org/pkg with https://pkg.go.dev. - Replace https://blog.golang.org with https://go.dev/blog. - Use https://pkg.go.dev/golang.org/x/net/http2 instead of non-existing https://http2.golang.org/. - Remove trailing slashes.
2023-02-09doc,test: correct typos (#1484)Gravatar Oleksandr Redko 1-4/+4
2022-11-28Revert "feat: support mulit/range (#1398)" (#1446)v1.43.0Gravatar Erik Dubbelboer 1-1/+1
This reverts commit a468a7dd3734d9866ef6ab8ee1e36695f5c3b09c.
2022-10-30feat: support mulit/range (#1398)Gravatar byene0923 1-1/+1
* feat: support mulit/range * fix: 1. lint code 2. add SetByteRanges method * fix: reduce the test number of testFSSingleByteRange
2022-10-29feat: add PeekKeys and PeekTrailerKeys (#1405)Gravatar kinggo 1-0/+40
* feat: add PeekKeys and PeekTrailerKeys * Improve warning Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2022-10-22optimize: adjust the behavior of PeekAll based on VisitAll (#1403)v1.41.0Gravatar kinggo 1-0/+12
2022-10-15feat: add header.PeekAll (#1394)Gravatar kinggo 1-0/+62
2022-07-29Improve Client timeout (#1346)Gravatar Erik Dubbelboer 1-4/+4
Don't run requests in a separate Goroutine anymore. Instead use proper conn deadlines to enforce timeouts. - Also contains some linting fixes.
2022-06-05Response.ContentEncoding(): store as field and avoid using ↵Gravatar Sergey Ponomarev 1-9/+57
Header.SetCanonical() (#1311) * Response.ContentEncoding(): store as field The CE is not so often used for plain APIs responses and even not so often used for static files and on the fly compression. But still it should be checked each time. Also having a dedicated field getter and setter simplifies code * header.go Use shorter Response.setNonSpecial() and Request.setNonSpecial() methods instead of SetCanonical() The change should improve performance because the setSpecialHeader() call is omitted. As a downside on adding a new basic header field all putHeader() must be replaced with a direct getter and setter.
2022-04-01Use %v for errors and %q for strings (#1262)v1.35.0Gravatar Erik Dubbelboer 1-91/+91
Mostly in tests.
2022-02-16RequestHeader support set no default ContentType (#1218)Gravatar Jack.Ju 1-0/+27
2021-12-05Add trailer support (#1165)Gravatar ichx 1-94/+223
* 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-11-08fix: Status Line parsing and writing (#1135)Gravatar Shivansh Vij 1-4/+33
* Adding zero-allocation uint64 to byte slice conversion and fixing the ResponseHeader.SetStatusLine function call signature * Removing unnecessary i2b function * Fixing various bugs * Adding test cases * Commenting AppendStatusLine * Update status.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> * Update header.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> * Cleaning up references to strHTTP11, using formatStatusLine for invalidStatusLine, and making `appendStatusLine` an unexported function Issue: https://github.com/valyala/fasthttp/issues/1132 * Fixing merge conflicts Issue: https://github.com/valyala/fasthttp/issues/1132 * Replacing []byte{} with nil in some test cases Issue: https://github.com/valyala/fasthttp/issues/1132 * Cleaning up parsing first line, and improving StatusMessage function Issue: https://github.com/valyala/fasthttp/issues/1132 * Fixing as per PR * Update header.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> * Update header.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> * Fixing as per requested changes * Update header_test.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2021-10-22feat: ability to edit status messages (#1126)Gravatar Valentin Paz Marcolla 1-1/+9
* SetStatusMessage * Docstring * statusLine in header * Use statusLine as []byte + ResponseHeader parsing * status line getter
2021-07-17fix typo: occured -> occurred (#1061)Gravatar Kazumasa Takenaka (Bamboo) 1-1/+1
2021-06-18Lower go test timeGravatar Erik Dubbelboer 1-0/+16
2021-06-01Fix header .Add functions (#1036)v1.26.0Gravatar Erik Dubbelboer 1-13/+34
These functions should take the headers that are handled differently into account.
2021-05-26Remove unused peekRawHeaderGravatar Erik Dubbelboer 1-29/+0
2021-05-17Use proper content-type when it is not present (#1023)Gravatar MoreFreeze 1-1/+27
Co-authored-by: liuchenxing <liuchenxing@bytedance.com>
2021-03-26Adding support for securing error logs (#1001)v1.23.0Gravatar Daniel Firsht 1-0/+73
Co-authored-by: Daniel Firsht <firsht@amazon.com>
2021-02-07fix gracefilly shutdown bug, issue #958 (#960)v1.20.0Gravatar AlphaBaby 1-0/+6
* fix gracefilly shutdown bug, issue #958 * fix golangci-lint * add option: CloseOnShutdown into Sever * Update server.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> * Update server.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> Co-authored-by: fujianhao3 <fujianhao3@jd.com> Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2020-08-07Add a api `DisableNoDefaultContentType` to disable add default content type. ↵Gravatar sky 1-3/+3
(#859) * Add api DisableNoDefaultContentType to disable add default contentype if no Content-Type header. * Update test case. * Update api name. * Update header.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2020-05-31Remove unused raw header codeGravatar Erik Dubbelboer 1-2/+2
2020-03-13Add support for `NoDefaultDate` option that excludes the sending of the ↵Gravatar phuslu 1-0/+14
`Date` header (#758)
2019-12-14Fix panic in header parserv1.7.0Gravatar Erik Dubbelboer 1-0/+8
2019-12-14Improve multiline header parsing (#708)Gravatar Erik Dubbelboer 1-21/+27
- Replace tabs with spaces at line starts to match net/http - Don't allow multi line header names. See: https://github.com/golang/go/issues/34702
2019-12-14add extra checking of header buffer, to support multi line header value ↵Gravatar tedli 1-0/+38
(#123) (#688)
2019-12-01Allow a body for GET requests (#703)Gravatar Erik Dubbelboer 1-23/+23
This means we can't skip parsing headers for GET requests anymore. This can be seen as good as it also allows us to reject malformed GET requests, something we didn't do before this. Performance also isn't affect much: benchmark old ns/op new ns/op delta BenchmarkClientGetEndToEnd1Inmemory-16 640 641 +0.16% BenchmarkClientGetEndToEnd10Inmemory-16 713 710 -0.42% BenchmarkClientGetEndToEnd100Inmemory-16 732 749 +2.32% BenchmarkClientGetEndToEnd1000Inmemory-16 759 774 +1.98% BenchmarkClientGetEndToEnd10KInmemory-16 785 808 +2.93% BenchmarkNetHTTPClientGetEndToEnd1Inmemory-16 5045 4954 -1.80% BenchmarkNetHTTPClientGetEndToEnd10Inmemory-16 5806 6225 +7.22% BenchmarkNetHTTPClientGetEndToEnd100Inmemory-16 7877 7998 +1.54% BenchmarkNetHTTPClientGetEndToEnd1000Inmemory-16 16603 16559 -0.27%
2019-11-16Run golangci-lint using a Github ActionGravatar Erik Dubbelboer 1-7/+9
2019-10-23Format errors (#679)Gravatar ZhangYunHao 1-4/+4
* format errors * Server is a type name * Fix typo
2019-10-16Speed up testing by running tests in parallelGravatar Erik Dubbelboer 1-0/+114
2019-10-16Don't allow spaces in request header keysGravatar Erik Dubbelboer 1-4/+3
See: https://github.com/golang/go/commit/6e6f4aaf70c8b1cc81e65a26332aa9409de03ad8 Reject any non GET or HEAD requests with a 400. We can't reject GET or HEAD requests with bad headers as we delay parsing of these headers until the user asks for one. So in this case we just ignore the header and don't return a value for it.
2019-08-13Correctly handle `NoDefaultContentType` without setting an `Content-Type` ↵Gravatar Ciprian Dorin Craciun 1-0/+13
value (#628) If `NoDefaultContentType` is set, but no actual `Content-Type` header is set, do not send the wrong `Content-Type: ` header