Commit Graph

84 Commits

Author SHA1 Message Date
Erik Dubbelboer c2b317d47d Go 1.26 and golangci-lint updates (#2146)
Keep Go 1.24 compatibility for now (by not using `wg.Go()`).
2026-02-21 10:28:39 +01:00
Erik Dubbelboer 7cf1fb7967 Add documentation that modifying during iteration can panic (#2122)
Fixes https://github.com/valyala/fasthttp/issues/2120
2026-01-05 15:10:34 +01:00
pj 7b5cb77b95 Add sortkeys (#2118)
* added Args.SortKeys

* add test for SortKeys

* fix comment
2025-12-29 15:00:35 -03:00
Erik Dubbelboer 81ebee8c79 Fix PeekKeys()
RequestHeader.PeekKeys() and ResponseHeader.PeekKeys() were both
implemented wrong. The tests were also wrong causing this to never be
noticed. They both never actually returned all header keys, this has
been fixed now.

While this is a backwards incompatible change, I'm still going to
release it. Anyone using these functions would have noticed they
didn't work as documented and probably would not have continued using
them.

Fixes https://github.com/valyala/fasthttp/issues/2044
2025-08-09 13:50:07 +02:00
Kashiwa a1783ffacc feat: Add iter.Seq2 iterator #2010 (#2011) 2025-05-18 13:23:04 +02:00
Kashiwa b59f47e3ee Refactor: split delAllArgs into delAllArgs and delAllArgsStable (#1945)
- Renamed the original `delAllArgs` method to `delAllArgsStable` to maintain stable behavior.
- Added a new `delAllArgs` method for non-stable functionality, improving runtime efficiency.
2025-02-19 19:48:10 +09:00
Kashiwa c908d9c1ee Refactor trailer Field for Improved Memory Efficiency and Performance (#1928)
* refact: represent trailer filed by [][]byte instead of []argsKV

* fix: address golangci-lint warnings
2025-01-29 05:53:12 +01:00
Kashiwa 2dfdfd86bf refactor: use buf in Args instead of bytebufferpool (#1931) 2025-01-03 00:05:43 +01:00
Oleksandr Redko 9d6b470260 chore: Add missing dots at the end of comments (#1677) 2023-12-13 13:56:24 +08:00
Oleksandr Redko f196617f55 chore: Use 'any' instead of 'interface{}' (#1666)
gofmt -w -r "interface{} -> any" -l .
2023-11-24 11:33:04 +01:00
Oleksandr Redko d3397c64ed Enable wastedassign, whitespace linters; fix issues (#1665) 2023-11-24 11:32:11 +01:00
Oleksandr Redko 9aa666e814 Enable gocritic linter; fix lint issues (#1612) 2023-08-29 20:08:37 +02:00
Oleksandr Redko eaab8ffc39 Refactor by removing unnecessary else block (#1559) 2023-05-11 10:01:44 +02:00
tyltr 5f4899ad5f remove (#1534) 2023-04-04 19:05:04 +02: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
hs son c57a2ce871 Make sure nothing is nil in tmp slice (#1423) 2022-11-14 18:15:41 +02:00
kinggo 3963a79a64 feat: add PeekKeys and PeekTrailerKeys (#1405)
* feat: add PeekKeys and PeekTrailerKeys

* Improve warning

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2022-10-29 18:57:40 +02:00
kinggo 2c8ce3b40e feat: add header.PeekAll (#1394) 2022-10-15 15:47:53 +02:00
Sergey Ponomarev 66cd5022fd header.go Referer() optimize (#1313)
* 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
1e7885eb56

* 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-06 08:46:49 +02:00
tyltr 9a0b4d088c optimize (#1275)
* opotimize

* lint

* without min

* less comparisons
2022-04-24 17:35:14 +02:00
tyltr e3d25122db optimize (#1272) 2022-04-19 18:39:32 +02:00
tyltr 2044e1e998 reduce unnessary type assart (#1254) 2022-03-18 08:19:34 +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 ffab77a59d Improve return value reusability documentation 2021-10-01 13:38:31 +02:00
Erik Dubbelboer 4e63057c0f Make argsKV more predictable
Fixes #932
2020-12-26 16:53:48 +01:00
anshul-jain-aws f710c2d320 Fixing deletion of headers/queryargs having multiple values. (#918) 2020-11-24 09:18:38 +01:00
Erik Dubbelboer 32793db72d Run golangci-lint using a Github Action 2019-11-16 18:09:28 +01:00
xuecai 627d63dd25 change timer to public api #525 (#527)
* change acquireTimer and releaseTimer to public api
2019-02-03 19:16:39 +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
xuecai c88be72d77 add method Sort in args (#505)
* add method StringSort QueryStringSort AppendBytesSort in args

* simplify code

* only Sort method

* format

* add method StringSort QueryStringSort AppendBytesSort in args

* simplify code

* only Sort method

* format

* merge and fix tests

* change sort into generic by having the sort function

* change sort into generic by having the sort function

* change comment
2019-01-04 18:38:56 +03:00
xuecai 4fb459a45e fix args empty string be changed to boolen (#502)
Add support for empty args
2018-12-30 19:56:58 +01: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 1e7885eb56 handle 't' and 'true' as bool in QueryArgs
See: https://github.com/erikdubbelboer/fasthttp/pull/46
2018-08-21 22:36:22 +08:00
xPushkin f24d00fcc6 A lot of typo fixes 2017-10-08 13:30:35 +01:00
Aliaksandr Valialkin ae643c872d decodeArgAppend code prettifying 2017-07-21 16:45:47 +03:00
Aliaksandr Valialkin 6ece3d9359 decodeArgAppend* optimization: remove bounds check when decoding percent-encoded string
Benchmark results:

name                           old time/op  new time/op  delta
AppendUnquotedArgSlowPath-4    68.9ns ± 2%  63.5ns ± 2%  -7.88%  (p=0.000 n=10+10)
2017-07-21 16:42:32 +03:00
Aliaksandr Valialkin d257ae60a3 ioptimized decodeArgAppend a bit
Benchmark results on linux/amd64:

name                           old time/op  new time/op  delta
ArgsParse-4                    72.8ns ± 2%  68.0ns ± 2%  -6.59%  (p=0.000 n=10+9)
AppendUnquotedArgFastPath-4    20.4ns ± 2%  21.1ns ± 9%    ~     (p=0.614 n=8+10)
AppendUnquotedArgSlowPath-4    68.9ns ± 3%  70.4ns ± 6%    ~     (p=0.148 n=9+10)
URIParsePath-4                 80.9ns ± 2%  78.7ns ± 2%  -2.80%  (p=0.000 n=10+10)
URIParsePathQueryString-4      88.9ns ± 1%  86.3ns ± 1%  -2.90%  (p=0.000 n=10+8)
URIParsePathQueryStringHash-4  95.7ns ± 8%  91.0ns ± 1%  -4.88%  (p=0.000 n=9+10)
URIParseHostname-4             98.6ns ± 1%  95.4ns ± 1%  -3.24%  (p=0.000 n=10+10)
2017-07-21 16:08:21 +03:00
Aliaksandr Valialkin 6ac0fd1a91 use more clear decodeArgAppend instead of misleading decodeArg 2017-06-20 18:19:36 +03:00
Aliaksandr Valialkin 2db9429ff7 added a fast path to decodeArgAppend when the arg doesnt contain encoded chars 2017-06-20 13:40:15 +03:00
Aliaksandr Valialkin b69eba7101 Added Args.GetBool helper 2017-01-30 19:47:15 +02:00
Aliaksandr Valialkin e9207dac9e Added Args.Add() 2016-03-29 16:49:42 +03:00
Aliaksandr Valialkin 6658e31fd0 Eliminated bufKV member from Args struct. This shaves off 16 bytes from RequestCtx struct 2016-03-29 16:37:29 +03:00
Aliaksandr Valialkin eca172369c Pass string key to hasArg instead of byte slice key 2016-03-29 16:31:38 +03:00
Aliaksandr Valialkin 0c67179812 Added delAllArgsBytes helper 2016-03-29 16:30:07 +03:00
Aliaksandr Valialkin 0d43464f64 Renamed unsafeBytes2Str to b2s 2016-03-29 16:26:21 +03:00
Aliaksandr Valialkin 8b26017325 Renamed setArg to setArgBytes 2016-03-29 16:19:22 +03:00
Aliaksandr Valialkin 2b172da539 re-use appendArg inside setArg 2016-03-15 11:27:03 +02:00
Aliaksandr Valialkin 3f6e5b64a9 optimized delAllArgs 2016-03-11 10:59:01 +02:00
Aliaksandr Valialkin 38356e216e Issue #64: properly delete header values via Del call 2016-03-10 17:22:59 +02:00
Aliaksandr Valialkin 8280b7a162 Moved empty noCopy struct to the top of container structs. See @stemar94 's comment at https://github.com/golang/go/issues/12884 for details 2016-03-06 00:17:08 +02:00