aboutsummaryrefslogtreecommitdiff
path: root/client.go
AgeCommit message (Collapse)AuthorFilesLines
2024-04-29Don't allow , in host when using Client (#1761)Gravatar Erik Dubbelboer 1-0/+5
When using a url like http://example.com,/ URI will parse "example.com," as host. HostClient then splits this by "," into multiple addresses and will connect to example.com. HostClient splitting the address by "," is only for direct use, not for use with Client.
2024-04-22fix: propagate body stream error to close function (#1743) (#1757)Gravatar Max Denushev 1-2/+2
* 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-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/+16
2023-12-05chore: Set max line length to 130 characters (#1676)Gravatar Oleksandr Redko 1-4/+12
2023-11-27add support for custom dial function with timeouts (#1669)Gravatar Aviv Carmi 1-30/+65
* add support for custom dial function with timeouts * fix linting --------- Co-authored-by: Aviv Carmi <aviv@perimeterx.com>
2023-11-24chore: Use 'any' instead of 'interface{}' (#1666)Gravatar Oleksandr Redko 1-2/+2
gofmt -w -r "interface{} -> any" -l .
2023-11-12Enable dupword, unconvert linters (#1658)v1.51.0Gravatar Oleksandr Redko 1-0/+1
2023-11-10Fix spelling mistakeGravatar Erik Dubbelboer 1-2/+2
Fixes #1654
2023-10-30Allow redirect URI path to not be normalized. (#1638)Gravatar Scott Kidder 1-2/+3
* Allow redirect URI path to not be normalized. * Introduce DisableRedirectPathNormalizing field to Request * Use field name as start of comment. Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> --------- Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2023-10-21BUGFIX: HostClient.DialDualStack not work when using DoDeadline (#1634)Gravatar chenyunfei 1-0/+3
Co-authored-by: chenyunfei.cs <chenyunfei.cs@bytedance.com>
2023-09-09Fix various request timeout issuesv1.50.0Gravatar Erik Dubbelboer 1-5/+27
A timeout of 0 should timeout immediately. When retrying requests the timeout should be updated to reflect the already passed time Fixes https://github.com/valyala/fasthttp/issues/1617
2023-09-02Allow connection close for custom streams (#1603)Gravatar Armin Becher 1-2/+5
* feat: allow connection close for custom streams * fix: avoid req access since might already be released * fix: fix aloc test fails * fix: race condition when clossing body stream
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-3/+3
2023-08-26Update golangci-lint and gosec (#1609)v1.49.0Gravatar Erik Dubbelboer 1-0/+1
2023-08-10Abstracts the RoundTripper interface and provides a default implement (#1602)Gravatar Tim 1-113/+129
* Abstracts the RoundTripper interface and provides a default implementation for enhanced extensibility (#1601) * test: Add custom transport test case (#1601) * Make default RoundTripper implmention none public Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> --------- Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2023-06-26Remove unnecessary indent blocks (#1586)Gravatar Oleksandr Redko 1-19/+15
2023-05-22Remove invalid documentationGravatar Erik Dubbelboer 1-20/+0
The Timeout functions don't use separate goroutines anymore and use normaly deadlines. Because of that requests are terminated and don't keep running in the background as before.
2023-05-14Request timeout settings for the same domain name are reused (#1558)Gravatar byte0o 1-14/+8
* Update client.go fix client http SetReadDeadline/SetWriteDeadline Deadline is reused * delete Deadline comments fix test singleEchoConn implement SetWriteDeadline/SetReadDeadline * fix test SetReadDeadline/SetWriteDeadline none implement --------- Co-authored-by: gaoping <gaoping1@wps.cn>
2023-05-12fix the problem: HostClient maybe delete when pendingClientRequests > 0 (#1562)Gravatar Zhengkai Wang 1-3/+6
* add the functions to get host clients * add concurrency for client's HostClient map * delete test code * add lock in once block * fix the problem: HostClient maybe delete when pendingClientRequests > 0 * fix the problem: HostClient maybe delete when pendingClientRequests > 0 --------- Co-authored-by: wangzhengkai.wzk <wangzhengkai.wzk@alibaba-inc.com>
2023-05-11add concurrency for client's HostClient map (#1550)Gravatar Zhengkai Wang 1-49/+53
* add the functions to get host clients * add concurrency for client's HostClient map * delete test code * add lock in once block --------- Co-authored-by: wangzhengkai.wzk <wangzhengkai.wzk@alibaba-inc.com>
2023-04-15client:Fix DoTimeout timeout failure by setting temporary dial (#1535)Gravatar kukayiyi 1-4/+12
2023-04-05support response body stream (#1414)Gravatar Anthony-Dong 1-2/+27
* 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-04format : update some codes style (#1533)Gravatar LeoSun 1-2/+1
* update some codes style * update adaptor.go and client.go * Update fasthttpproxy/http.go Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com> --------- Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2023-03-30get rid of some panics (#1526)Gravatar Moritz Poldrack 1-7/+4
* 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-14client: HostClient.Do hangs out when ErrConnPoolStrategyNotImpl (#1515)Gravatar Oleksandr Redko 1-0/+1
2023-03-11client: fix Do hangs when configure host client fails (#1514)Gravatar Oleksandr Redko 1-0/+1
2023-03-06client: remove unused go:build comment (#1511)Gravatar Oleksandr Redko 1-2/+0
2023-03-03Immediately return ErrTimeout if deadline is already reached. (#1497)Gravatar Igor Menshenin 1-0/+16
* fix: Immediately return ErrTimeout if deadline is already reached. * test: Added tests for negative timeout --------- Co-authored-by: Igor Menshenin <igor@native.rent>
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-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-10Rename unexported funcs, vars to match common Go (#1488)Gravatar Oleksandr Redko 1-7/+7
See https://github.com/golang/go/wiki/CodeReviewComments#initialisms and https://go.dev/doc/effective_go#mixed-caps
2023-02-09doc,test: correct typos (#1484)Gravatar Oleksandr Redko 1-1/+1
2023-01-02client.go Simplify default UA logic (#1466)Gravatar Sergey Ponomarev 1-36/+21
The getClientName() checks if !NoDefaultUserAgentHeader then returns the Client.Name field. But it also saves it to atomic field clientName. This is not needed and logic can be simplified. Previously the clientName vas a byte slice that was copied from c.Name and cached. See 02e0722fb73c6237818b8e5af55957eb919a7334 Fix #1458
2022-12-29fix: client may remove hostclient incorrectly (#1461)Gravatar Xuran 1-1/+1
2022-11-28client.go fix addMissingPort() (#1444)Gravatar Sergey Ponomarev 1-9/+25
* client.go Make addMissingPort() public It's needed for those who creates the instance of the HostClient manually. * client.go fix AddMissingPort() Previously for IPv6 addresses the default port wasn't added. The fix adding a test and optimization that should avoid itoa() call and reduce a memory usage
2022-11-17Wait for the response of pipelineWork in background and return it to pool ↵Gravatar Andy Pan 1-40/+40
(#1436)
2022-11-16Fix some potential pool leaks (#1433)Gravatar Andy Pan 1-1/+2
2022-11-16Use time.Until(deadline) instead of -time.Since(deadline) (#1434)Gravatar Andy Pan 1-2/+2
2022-09-03Improve isTLSAlready checkv1.40.0Gravatar Erik Dubbelboer 1-1/+5
All conn implementations having a Handshake() error method are now seen as a TLS conn and aren't wrapped in another tls.Client.
2022-08-28Don't use tls ClientSessionCacheGravatar Erik Dubbelboer 1-4/+0
net/http doesn't use it either. Some servers have issues with this preventing fasthttp from working: https://github.com/valyala/fasthttp/issues/1364 https://github.com/valyala/fasthttp/issues/1296 https://github.com/valyala/fasthttp/issues/1335 https://github.com/valyala/fasthttp/issues/984 Also removed code that benchmarks crypto/tls as that has nothing to do with fasthttp.
2022-08-14Add Go 1.19 Support (#1355)v1.39.0Gravatar Aoang 1-1/+1
* 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-91/+14
Don't run requests in a separate Goroutine anymore. Instead use proper conn deadlines to enforce timeouts. - Also contains some linting fixes.
2022-07-06use timeout insteadof read/writetimeout when timeout lower than read/… (#1336)Gravatar fare83 1-4/+21
* use timeout insteadof read/writetimeout when timeout lower than read/writetimeout * use deadtime; fix test timeout; Co-authored-by: 徐焱 <xuyan4@staff.sina.com.cn>
2022-06-07Add `ConnPoolStrategy` field to client (#1317)Gravatar Thearas 1-0/+4
2022-04-10Update tlsClientHandshake (#1263)Gravatar Mikhail Faraponov 1-30/+22
* Update tlsClientHandshake * Update client.go * Update client.go * Update client.go * Update client.go * Changes according to the review
2022-04-01Use %v for errors and %q for strings (#1262)v1.35.0Gravatar Erik Dubbelboer 1-1/+1
Mostly in tests.
2022-03-20Add Go 1.18 support (#1253)Gravatar Aoang 1-2/+2
* 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