aboutsummaryrefslogtreecommitdiff
path: root/header.go
AgeCommit message (Collapse)AuthorFilesLines
2024-03-02Enable perfsprint linter; fix up lint issues (#1727)Gravatar Oleksandr Redko 1-9/+9
2024-03-02Enable few gocritic checks; fix up issues (#1728)Gravatar Oleksandr Redko 1-2/+2
2024-02-11Prevent request smuggling (#1719)v1.52.0Gravatar Erik Dubbelboer 1-1/+18
* 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-10/+26
Require that HTTP versions match the following pattern: HTTP/[0-9]\.[0-9]
2024-01-07refactor: move manually created tchar table to bytesconv_table_gen (#1689)Gravatar nickajacks1 1-20/+1
2024-01-02feat: add function to parse HTTP header parameters (#1685)Gravatar nickajacks1 1-0/+98
* feat: add function to parse HTTP header parameters The implementation is based on RFC-9110 5.6.6. * test: add fuzz for VisitHeaderParams
2023-12-13chore: Add missing dots at the end of comments (#1677)Gravatar Oleksandr Redko 1-6/+6
2023-09-22reset request disableSpecialHeader (#1626)Gravatar xiluoxi 1-0/+1
2023-08-29Enable gocritic linter; fix lint issues (#1612)Gravatar Oleksandr Redko 1-17/+22
2023-07-02Auto add 'Vary' header after compression (#1585)Gravatar AutumnSun 1-0/+12
* 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-12add DisableSpecialHeaders option (#1573)Gravatar Anthony Ter-Saakov 1-7/+39
* 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-03fix functiom name (#1505)Gravatar cui fliter 1-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-02-13docs: fix grammar issues and typos in comments (#1492)Gravatar Oleksandr Redko 1-1/+1
2023-02-11Refactor golangci-lint config and remove redundant nolints (#1486)Gravatar Oleksandr Redko 1-2/+2
* Refactor golangci-lint config - Use golangci-lint-action for GitHub workflow. - Add additional golangci-lint run options. - Remove unused nolint directives. * Revert exclude-use-default option
2023-02-09doc,test: correct typos (#1484)Gravatar Oleksandr Redko 1-1/+1
2022-11-28Revert "feat: support mulit/range (#1398)" (#1446)v1.43.0Gravatar Erik Dubbelboer 1-18/+9
This reverts commit a468a7dd3734d9866ef6ab8ee1e36695f5c3b09c.
2022-11-18style: modify typo and remove repeated type conversions (#1437)Gravatar kinggo 1-1/+1
2022-10-30feat: support mulit/range (#1398)Gravatar byene0923 1-9/+18
* 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-1/+51
* feat: add PeekKeys and PeekTrailerKeys * Improve warning Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2022-10-29fix: (#1410)Gravatar byene0923 1-1/+1
1. the length of trailer key should > 0 2. fix http_test words typo
2022-10-22optimize: adjust the behavior of PeekAll based on VisitAll (#1403)v1.41.0Gravatar kinggo 1-7/+18
2022-10-15feat: add header.PeekAll (#1394)Gravatar kinggo 1-0/+83
2022-08-14Add Go 1.19 Support (#1355)v1.39.0Gravatar Aoang 1-34/+34
* Update Go Version to Go1.19.x And add cache * Fix CI Line endings * Update test CI Go Version to Go1.19.x And add cache * Update Gosec Security Scanner CI to securego/gosec@v2.12.0 * Format comment Go 1.19 adds support for links, lists, and clearer headings in doc comments. As part of this change, gofmt now reformats doc comments to make their rendered meaning clearer. See “Go Doc Comments” for syntax details and descriptions of common mistakes now highlighted by gofmt. As another part of this change, the new package go/doc/comment provides parsing and reformatting of doc comments as well as support for rendering them to HTML, Markdown, and text. ref: https://tip.golang.org/doc/go1.19 ref: https://tip.golang.org/doc/comment * Fix doc structure
2022-07-29Improve Client timeout (#1346)Gravatar Erik Dubbelboer 1-3/+3
Don't run requests in a separate Goroutine anymore. Instead use proper conn deadlines to enforce timeouts. - Also contains some linting fixes.
2022-06-06BodyDecoded() for request and responses (#1308)Gravatar Sergey Ponomarev 1-0/+15
* header.go ContentEncoding() getter and setters For Response the CE header is stored into a separate field because compressed responses are often used. But for the Request let's just peek and store it from headers map * http.go: New BodyUncompressed() method for request and responses The new method returns a body and uncompress if it's gzipped
2022-06-06header.go Referer() optimize (#1313)Gravatar Sergey Ponomarev 1-1/+1
* args.go GetBool(): use switch with string casting This should be optimized by Go compiler itself so the b2s() call is not needed. It was previously done by this but changed in 1e7885eb56cdf4c6f550e143b0dbd3acc82a4137 * header.go Referer() optimize Use direct peekArgBytes() instead of PeekBytes() that will check for special headers * header_timing_test.go BenchmarkRequestHeaderPeekBytesSpecialHeader The old BenchmarkRequestHeaderPeekBytesCanonical and BenchmarkRequestHeaderPeekBytesNonCanonical are in fact just measured the header normalization. But it's anyway is benchmarked separately. Results was almost the same: 1.5 ns/op. Instead, let's reuse the benches to find a difference between peeking of special (Host, CT) and custom headers.
2022-06-05Response.ContentEncoding(): store as field and avoid using ↵Gravatar Sergey Ponomarev 1-12/+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-1/+1
Mostly in tests.
2022-03-01Fix panic while reading invalid trailersGravatar Erik Dubbelboer 1-0/+4
2022-02-16RequestHeader support set no default ContentType (#1218)Gravatar Jack.Ju 1-4/+11
2022-01-10Make tests less flaky (#1189)v1.32.0Gravatar Erik Dubbelboer 1-1/+1
2021-12-13Use %w to wrap errors (#1175)Gravatar Erik Dubbelboer 1-12/+12
2021-12-13Fix bad request trailer panicGravatar Erik Dubbelboer 1-1/+5
2021-12-06Fix parseTrailer panicGravatar Erik Dubbelboer 1-2/+14
2021-12-05Add trailer support (#1165)Gravatar ichx 1-9/+633
* 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-20/+34
* 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-30chore (#1137)Gravatar tyltr 1-1/+1
2021-10-22feat: ability to edit status messages (#1126)Gravatar Valentin Paz Marcolla 1-1/+25
* SetStatusMessage * Docstring * statusLine in header * Use statusLine as []byte + ResponseHeader parsing * status line getter
2021-10-19remove redundant code (#1127)Gravatar tyltr 1-11/+11
2021-10-01Improve return value reusability documentationGravatar Erik Dubbelboer 1-7/+15
2021-09-10Check go fmt during lint (#1097)Gravatar Erik Dubbelboer 1-5/+5
2021-09-07Adding new compressible prefixes (#1092)v1.30.0Gravatar Kyle Unverferth 1-1/+5
* 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-06feat: improve IsMethod (#1088)Gravatar tyltr 1-10/+10
* 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-06-28Flush buffered responses if we have to wait for the next request (#1050)Gravatar Erik Dubbelboer 1-1/+8
* Flush buffered responses if we have to wait for the next request Don't wait for the next request as this can take some time, instead flush the outstanding responses already. Fixes #1043 * Only peek 1 byte Make sure old clients that send bogus \r\n still work. See: https://github.com/golang/go/commit/bf5e19fbaf02b1b25fbe50c27ec301fe830a28d0
2021-06-01Fix header .Add functions (#1036)v1.26.0Gravatar Erik Dubbelboer 1-64/+148
These functions should take the headers that are handled differently into account.
2021-05-26Remove unused peekRawHeaderGravatar Erik Dubbelboer 1-31/+0
2021-05-17Use proper content-type when it is not present (#1023)Gravatar MoreFreeze 1-8/+8
Co-authored-by: liuchenxing <liuchenxing@bytedance.com>
2021-03-26Adding support for securing error logs (#1001)v1.23.0Gravatar Daniel Firsht 1-7/+32
Co-authored-by: Daniel Firsht <firsht@amazon.com>
2021-02-16Added Protocol() as a replacement of hardcoded strHTTP11 (#969)Gravatar Darío 1-1/+29
* Added Protocol() as a replacement of hardcoded strHTTP11 * Applied review changes * Modify h.proto in parseFirstLine