Commit Graph

133 Commits

Author SHA1 Message Date
Erik Dubbelboer df8335f9ab A response without a body can't have trailers (#1825) 2024-08-20 23:10:04 +02:00
Max Denushev 57b9352ad1 fix: propagate body stream error to close function (#1743) (#1757)
* fix: propagate body stream error to close function (#1743)

* fix: http test

* fix: close body stream with error in encoding functions

* fix: lint

---------

Co-authored-by: Max Denushev <denushev@tochka.com>
2024-04-22 08:45:33 +02:00
Oleksandr Redko bdd459ab0e test: remove //nolint:govet comments (#1729) 2024-03-02 16:19:52 +01:00
Oleksandr Redko 3166afd835 Enable few gocritic checks; fix up issues (#1728) 2024-03-02 16:19:05 +01:00
Oleksandr Redko 190204cf1a Upgrade golangci-lint to v1.56.2; fix gocritic issues (#1722) 2024-02-21 05:51:28 +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
Erik Dubbelboer a04cd8c39f Move Fuzz tests into their own file
This is required for https://github.com/google/oss-fuzz/pull/11453
2024-01-09 13:01:31 +01:00
nickajacks1 f0905a14d1 test: migrate remaining fuzzit tests to go 1.18 fuzzing (#1687) 2024-01-06 13:39:23 +08:00
Oleksandr Redko 28615eba55 Change empty string checks to be more idiomatic (#1684) 2024-01-04 15:05:38 +01:00
Oleksandr Redko 8ecfc989d9 Enable dupword, unconvert linters (#1658) 2023-11-12 16:42:39 +01:00
Oleksandr Redko 4ec5c5a774 docs: fix typos in comments and tests 2023-08-30 14:13:13 +02:00
Duncan Overbruck 6aea1e0d44 fix round2_32, split round2 tests because they depend on sizeof int at compile time (#1607) 2023-08-24 20:39:33 +02:00
Erik Dubbelboer 1c85d43dfe Fix round2
- don't limit it to 32 bits
- give it a proper name
- don't over-allocate too much
2023-07-08 12:40:36 +02:00
Oleksandr Redko ffdf59d04c Enable gofumpt linter; format code gofumpt -w . (#1576) 2023-06-13 15:18:59 +02:00
Erik Dubbelboer fa72f3cc39 Fix tests (#1552) 2023-05-07 14:32:14 +02:00
Oleksandr Redko 1dcf56222d test: refactor to use WriteString (#1546) 2023-04-28 17:39:58 +02:00
Oleksandr Redko 1aac29366c test: use ReplaceAll, remove unnecessary else (#1542) 2023-04-25 13:17:59 +02:00
Abe Saiovici d76662b46d Fixed transfer-encoding for empty chunked payload (#1536) 2023-04-12 22:51:30 +02:00
Anthony-Dong 6b958c2c22 support response body stream (#1414)
* feat: support response body stream

* style: add header interface

* Update http.go

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

* feat: support request、response、client stream

* fix: close reader bug

---------

Co-authored-by: fanhaodong.516 <fanhaodong.516@bytedance.com>
Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2023-04-05 18:56:31 +02:00
Oleksandr Redko 0be5a4150c test: simplify bytes.Buffer declaration (#1523) 2023-03-18 14:40:25 +01:00
Oleksandr Redko 934f04e330 Refactor golangci-lint config and remove redundant nolints (#1486)
* 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-11 15:35:15 +08:00
Oleksandr Redko c0c5f9cd38 doc,test: correct typos (#1484) 2023-02-09 09:29:28 +01:00
kinggo e87f84c51a fix: CopyTo doesn't copy bodyraw deeply (#1471) 2023-01-14 10:44:11 +08:00
nick9822 c88dd5dc02 fix form empty field error when used with pipe (#1417)
Co-authored-by: root <nikesh.tawde@digitalairtech.com>
2022-11-03 21:24:53 +01:00
byene0923 eca86de6f6 fix: (#1410)
1. the length of trailer key should > 0
2. fix http_test words typo
2022-10-29 18:32:18 +02:00
byene0923 e2141372b6 fix: ignore body should not set content-length of streaming (#1406)
* fix: ignore body should not set content-length of streaming https://github.com/valyala/fasthttp/pull/1022

* fix: add commit
2022-10-29 18:32:08 +02:00
Aoang a696949f6c Deprecate Go 1.15 (#1379)
* Dropping support for 1.15.

* Replaces Go 1.16 Deprecated functions

* Update test build flag

* Fix import sort and comment

* Update github.com/klauspost/compress to v1.15.9

https://github.com/klauspost/compress improved performance and changed Minimum version is 1.16, this should be the final supported release for Go 1.16 (https://github.com/klauspost/compress/commit/6d0019a95afa3221f7522d1f2eed0033b5e79470) .
2022-09-15 22:28:25 +03:00
mathew 42f83c60cf Prevent overflow and panic on large HTTP responses (#1351) 2022-07-29 18:58:52 +02:00
Sergey Ponomarev 35aca7b6df BodyDecoded() for request and responses (#1308)
* 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-06 08:59:16 +02:00
Sergey Ponomarev c9f43eaa1b Response.ContentEncoding(): store as field and avoid using 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-06-05 15:47:59 +02:00
Erik Dubbelboer 7a5afddf5b Use %v for errors and %q for strings (#1262)
Mostly in tests.
2022-04-01 18:11:16 +02:00
Erik Dubbelboer 1116d034d5 Fix panic while reading invalid trailers 2022-03-01 20:50:12 +01:00
Tolyar c727b9981b Release UseHostHeader in ReleaseRequest() (#1185)
* Fix UseHostHeader for DoTimeout + tests

* Release UseHostHeader in ReleaseRequest() + tests
2021-12-28 19:26:04 +08:00
Tolyar 6c0518b89a Fix UseHostHeader for DoTimeout + tests (#1184) 2021-12-26 21:08:23 +08:00
Tolyar 4517204499 Allow to set Host header for Client (#1169)
* Allow to set Host header for Client

* Allow to change Host header without tests violation

* Rename AllowToChangeHostHeader and add tests.

* Allow to use empty uri.Host() when req.Header.Host() does not empty
2021-12-17 06:26:17 +01:00
Erik Dubbelboer e9db537178 Use %w to wrap errors (#1175) 2021-12-13 09:41:34 +01:00
Erik Dubbelboer 7db0597e75 Fix bad request trailer panic 2021-12-13 09:01:16 +01:00
Erik Dubbelboer 4aadf9a85e Fix parseTrailer panic 2021-12-06 14:48:36 +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
Sergey Ponomarev 8febad0797 http.go: Request.SetURI() (Fix #1141) (#1148)
Currently, the only way to set URI for a request is to call SetRequestURI(string).
Then when a request performed the string will be parsed into a fasthttp.URI struct.
If there are many requests with the same URI then we'll waste CPU for a parsing of the same URI string.
With the new SetURI(*URI) method we can once parse a URI string into a fasthttp.URI struct and then reuse it for many requests.
Unfortunately the URI will be copied because may be modified inside the request.
But anyway this will be more lightweight than parsing.
2021-11-08 13:09:35 +01:00
Shivansh Vij 2ca01c7efb fix: Status Line parsing and writing (#1135)
* 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-11-08 09:44:02 +01:00
Valentin Paz Marcolla 556aa814e4 feat: ability to edit status messages (#1126)
* SetStatusMessage

* Docstring

* statusLine in header

* Use statusLine as []byte + ResponseHeader parsing

* status line getter
2021-10-22 17:53:35 +02:00
Erik Dubbelboer 9f2c63676d Lower go test time 2021-06-18 14:57:18 +02:00
MoreFreeze 097fa05a69 Fix ignoreBody still set content length (#1022)
* Fix ignore body should not set content-length

* Add TestRequestReadNoBody

Co-authored-by: liuchenxing <liuchenxing@bytedance.com>
2021-05-14 10:08:51 +02:00
Vladimir Shteinman 0cd7349686 ImmediateHeaderFlush when no body (#995) 2021-03-15 18:10:51 +01:00
Erik Dubbelboer 70e00dc4f3 Ignore empty Transfer-Encoding headers
Don't default to chunked. If we have a Content-Length header we have a fixed body.
2021-01-06 19:18:12 +01:00
Kirill Danshin d0dfbd4494 fix issue #875 (#909)
* 🐞 panic in fs.go #824

* fix issue #875

Signed-off-by: Kirill Danshin <kirill@danshin.pro>

* improve issue 875

Co-authored-by: Fenny <fenny@gofiber.io>

* Update header.go

* Update header.go

Co-authored-by: Kirill Danshin <kirill@danshin.pro>

* remove foldReplacer

* Improve removeNewLines

Start replacing at the first character found, use bytes.Indexbyte to
make the function signature more logical. Both bytes.indexByte and
strings.IndexByte use exactly the same code:
https://github.com/golang/go/blob/0c703b37dffe74d3fffc04347884bb0ee2fba5b3/src/internal/bytealg/indexbyte_amd64.s#L8-L20

Co-authored-by: wernerr <rene.werner@verivox.com>
Co-authored-by: wernerr <rene@gofiber.io>
Co-authored-by: Fenny <fenny@gofiber.io>
Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2020-12-09 16:59:57 +01:00
Erik Dubbelboer ce7b94fee9 Add Request.SetBodyRaw
Fixes https://github.com/valyala/fasthttp/issues/891
2020-11-02 22:22:01 +01:00
Erik Dubbelboer 34a61fe63f Update linting (#851) 2020-07-17 14:22:28 +02:00
Markmerc db18810c87 Add configuration to not pre-parse multipart form data (#778)
Co-authored-by: Mercurio <mmmercur@amazon.com>
2020-04-14 18:17:57 +02:00