aboutsummaryrefslogtreecommitdiff
path: root/server.go
AgeCommit message (Collapse)AuthorFilesLines
2024-04-21refactor: do not return error as it is always nil (#1759)Gravatar Oleksandr Redko 1-7/+7
2024-03-25refactor: rename error local variables (#1738)Gravatar Oleksandr Redko 1-2/+2
2024-03-02Enable few gocritic checks; fix up issues (#1728)Gravatar Oleksandr Redko 1-1/+1
2024-02-21feat:support zstd compress and uncompressed (#1701)Gravatar Co1a 1-2/+7
* 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-10Implement `GetRejectedConnectionsCount` function (#1704)Gravatar mopeneko 1-0/+10
* Implement `GetRejectedConnectionsCount` * Implement test for `GetRejectedConnectionsCount`
2024-01-04Change empty string checks to be more idiomatic (#1684)Gravatar Oleksandr Redko 1-1/+1
2023-12-13chore: Add missing dots at the end of comments (#1677)Gravatar Oleksandr Redko 1-16/+19
2023-12-05chore: Set max line length to 130 characters (#1676)Gravatar Oleksandr Redko 1-6/+12
2023-12-02bug: Flush the write buffer before putting it to the pool (#1672)Gravatar Jille Timmermans 1-1/+1
A few lines later we check if `s.ReduceMemoryUsage && hijackHandler == nil` and call releaseWriter. We need to flush the buffer before returning it to the pool to avoid the data getting lost.
2023-11-24chore: Use 'any' instead of 'interface{}' (#1666)Gravatar Oleksandr Redko 1-10/+10
gofmt -w -r "interface{} -> any" -l .
2023-11-24Enable wastedassign, whitespace linters; fix issues (#1665)Gravatar Oleksandr Redko 1-6/+3
2023-10-06Don't put hijackConn structure back to the pool on Close if ↵Gravatar Alexander Kolesov 1-3/+1
KeepHijackedConns is enabled. (#1629)
2023-08-30docs: fix typos in comments and testsGravatar Oleksandr Redko 1-1/+1
2023-08-29Enable gocritic linter; fix lint issues (#1612)Gravatar Oleksandr Redko 1-6/+8
2023-07-18fix:fasthttp server with tlsConfig (#1595)Gravatar Zhang Xiaopei 1-17/+14
* fix:fasthttp server with tlsConfig Signed-off-by: zhangweiyu <zhangweiyu2@huawei.com> * fix:fasthttp server with tlsConfig Signed-off-by: zhangweiyu <zhangweiyu2@huawei.com> * Update server.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> * fix:fasthttp server with tlsConfig Signed-off-by: zhangweiyu <zhangweiyu2@huawei.com> * fix:fasthttp server with tlsConfig Signed-off-by: zhangweiyu <zhangweiyu2@huawei.com> --------- Signed-off-by: zhangweiyu <zhangweiyu2@huawei.com> Co-authored-by: zhangweiyu <zhangweiyu2@huawei.com> Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2023-06-26Remove unnecessary indent blocks (#1586)Gravatar Oleksandr Redko 1-9/+6
2023-06-13Enable gofumpt linter; format code `gofumpt -w .` (#1576)v1.48.0Gravatar Oleksandr Redko 1-4/+2
2023-03-30get rid of some panics (#1526)Gravatar Moritz Poldrack 1-9/+8
* client: simplify (*HostClient).do() Remove an allocation in favour of deferring a call to release the response. * client: remove panic in dialAddr Return an error instead of panicking if the user supplied a nonsensical DialFunc. * compression: remove panic on invalid compression level If a compression level exceeding gzip's boundaries is provided, fasthttp will panic. Instead it would be better to handle this error for them by limiting it to the minimum or maximum value, depending on the direction the user has exceeded the limits. Clamp the value of gzip to always be between gzip.BestSpeed and gzip.BestCompression. * peripconn: remove panic on negative connection count When a negative count is reached when unregistering a connection, a panic is caused even though data-integrity is not at risk. Replace the panic() with a simple clamp on the value to ensure the value does not exceed it's expected lower bounds. References: #1504 * compress: remove error on failed nonblocking writes Since there is no way of handling or even logging non-critical errors in stateless non-blocking writecalls, just drop them and hope the user notices and tries again. * workerPool: remove panic on redundant Start and Stop calls Instead of panicking for invalid behaviour, it's preferable to just turn the function into a noop. * http: remove panic on invalid form boundary * http: remove panic on negative reads Since bufio already panics on negative reads, it is not necessary to do so as well. If the length is zero and for some reason no error is returned, readBodyIdentity and appendBodyFixedSize now errors in these cases. Link: https://github.com/golang/go/blob/851f6fd61425c810959c7ab51e6dc86f8a63c970/src/bufio/bufio.go#L246 * fs: remove panic on negative reader count When a negative count is reached when unregistering a reader, a panic is thrown even though data-integrity is not at risk. Replace the panic() with a simple clamp on the value to ensure the value does not exceed it's expected lower bounds. * server: remove panic in favour of a segfault Panicking with "BUG: " obscures the error. As the segfault causes a panic anyway, just let the chaos unfold. * server: remove panic in favour of returning an error Writing on a timed-out response is not endangering data integrity and just fails. * chore: add comments to all panics * chore: fix minor typo
2023-03-06test: fix typos in function, error message, comment (#1512)Gravatar Oleksandr Redko 1-1/+1
2023-02-13docs: Deprecate ErrAlreadyServing as never returning (#1491)Gravatar Oleksandr Redko 1-2/+1
2023-02-13docs: fix grammar issues and typos in comments (#1492)Gravatar Oleksandr Redko 1-8/+8
2023-02-11Refactor golangci-lint config and remove redundant nolints (#1486)Gravatar Oleksandr Redko 1-4/+4
* 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
2023-01-06server.go Simplify default Server name logic (#1467)Gravatar Sergey Ponomarev 1-25/+15
The serverName atomic.Value field is used as a cache. This is not needed and logic can be simplified. See related #1458
2022-12-25optimize: allow http head when use getonly (#1456)Gravatar kinggo 1-1/+1
2022-12-25feat: support custom formvalue function (#1453)Gravatar kinggo 1-14/+54
2022-12-18doc: optimize the comment of the Request.Done method (#1454)Gravatar kinggo 1-0/+6
2022-11-20feat: add ShutdownWithContext (#1383)v1.42.0Gravatar kinggo 1-4/+24
2022-11-18style: modify typo and remove repeated type conversions (#1437)Gravatar kinggo 1-1/+1
2022-11-15Assert with *net.TCPConn instead of *net.TCPListener in acceptConn() for TCP ↵Gravatar Andy Pan 1-21/+15
sockets (#1432) Make the code more succinct.
2022-10-06make RequestCtx's userdata accept keys that are of type: interface{} (#1387)Gravatar pj 1-8/+18
Co-authored-by: rocketlaunchr-cto <rocketlaunchr.cloud@gmail.com>
2022-08-26Fix "use of closed network connection" error checkGravatar Erik Dubbelboer 1-11/+11
This was refactored out incorrectly in a previous change.
2022-08-23Fix(server): reset maxRequestBodySize to the server's config (#1360)Gravatar Geralt X Li 1-0/+6
* fix(server): reset maxRequestBodySize to the server's config when HeaderReceived is set * fix(server): reset writeTimeout
2022-08-14Add Go 1.19 Support (#1355)v1.39.0Gravatar Aoang 1-46/+43
* 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-06-28Close new connections after 5s in closeIdleConnsGravatar Erik Dubbelboer 1-8/+18
When calling closeIdleConns() also close new connections that haven't received any data within 5 seconds. Some applications open new connections but don't send anything and keep them as keep-alive for potential future requests. We don't want to keeping hanging on these when shutting down a server.
2022-06-20Consolidate TCPKeepalive in server.Serve (#1320) (#1324)Gravatar Y.Horie 1-50/+21
2022-06-05Response.ContentEncoding(): store as field and avoid using ↵Gravatar Sergey Ponomarev 1-2/+2
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-05Optimize server connection close logic (#1310)Gravatar Sergey Ponomarev 1-10/+8
* server.go Make code more clear Inline isHTTP11 var. Use direct Header.SetConnectionClose() and Header.ConnectionClose() * server.go Use direct SetConnectionClose() The SetCanonical(strConnection, strClose) call internally will anyway call SetConnectionClose(). The "Connection: close" will be printed in the ResponseHeader.AppendBytes() * server.go Simplify connectionClose evaluation The conn limit check merged into connectionClose evaluation. This improves performance for most cases: 1. If the connectionClose already true then the conn limit check won't be performed. 2. The SetConnectionClose() was duplicated 3. First check conn limit and only then check for resp.connClose because most users don't close conns manually. 4. We may optimize more: If the resp.connClose = true then SetConnectionClose() not needed but as mentioned above this is a rare case.
2022-04-26Fix DoTimeout Streaming body bugv1.36.0Gravatar Erik Dubbelboer 1-0/+1
2022-04-01Use %v for errors and %q for strings (#1262)v1.35.0Gravatar Erik Dubbelboer 1-9/+9
Mostly in tests.
2022-04-01Only set RequestCtx.s onceGravatar Erik Dubbelboer 1-1/+1
We have a RequestCtx pool per server so we only need to set it once. This fixes a race codition where acquireCtx would assign .s while .Done() is reading it. Even though acquireCtx would always set it to the same, already assigned, value it would still trigger the race detector. Fixes: https://github.com/valyala/fasthttp/issues/1261
2022-04-01State active (#1260)Gravatar Erik Dubbelboer 1-8/+5
* Require at least Go 1.15 * Fix StateActive state * Don't panic when idle connections get closed
2022-03-20Add Go 1.18 support (#1253)Gravatar Aoang 1-4/+4
* Add Go 1.18 support * fix Gosec Security Scanner https://github.com/valyala/fasthttp/runs/5595618634?check_suite_focus=true * fix https://github.com/securego/gosec/issues/469#issuecomment-1070608395 Gosec Github Action Doesn't Work at Go 1.18 * fix https://github.com/golangci/golangci-lint/pull/2438 golangci/golangci-lint Doesn't Work at Go 1.18 * fix golint unused * fix golint: SA1019: netErr.Temporary is deprecated * fix https://github.com/valyala/fasthttp/issues/1256
2022-03-04Don't reset RequestCtx.s (#1234)Gravatar Erik Dubbelboer 1-1/+6
RequestCtx's are reused in a server specific pool, so no need to reset it. This fixes a use after reset but when RequestCtx is use as context. Fixes #1205
2022-03-03Warn about unsafe ServeFile usage (#1228)Gravatar Erik Dubbelboer 1-0/+8
See: https://github.com/valyala/fasthttp/issues/1226
2022-02-20fix: (useless check), skip Response body if http method HEAD (#1224)Gravatar Pavel Burak 1-1/+1
2022-01-22fix(hijack): reuse RequestCtx (#1201)Gravatar Sergio VS 1-28/+44
* fix(hijack): reuse RequestCtx * fix(test/hijack): increase wait time * fix(test/hijack): wait for all connections to finish to check responses
2022-01-18fix(hijack): reset userValues after hijack handler execution (#1199)Gravatar Sergio VS 1-2/+4
* fix(hijack): reset userValues after hijack handler execution * feat: add test * fix: typo * fix(test): race condition
2021-12-26Add MaxIdleWorkerDuration to Server. (#1183)Gravatar Kilos Liu 1-5/+10
2021-12-16fix: reset response after reset user values on keep-alive connections (#1176)Gravatar Sergio VS 1-5/+12