aboutsummaryrefslogtreecommitdiff
path: root/client_test.go
diff options
context:
space:
mode:
authorGravatar Oleksandr Redko <oleksandr.red+github@gmail.com> 2023-03-11 18:48:33 +0200
committerGravatar GitHub <noreply@github.com> 2023-03-11 17:48:33 +0100
commit7846101dc65ee5e02cea672af4594e3a80048632 (patch)
treef7c47f6979d427dd4510a1147ebcbc00acd52f29 /client_test.go
parentFix proxy auth bug (diff)
downloadfasthttp-7846101dc65ee5e02cea672af4594e3a80048632.tar.gz
fasthttp-7846101dc65ee5e02cea672af4594e3a80048632.tar.bz2
fasthttp-7846101dc65ee5e02cea672af4594e3a80048632.zip
client: fix Do hangs when configure host client fails (#1514)
Diffstat (limited to 'client_test.go')
-rw-r--r--client_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/client_test.go b/client_test.go
index cf98531..fc42b2d 100644
--- a/client_test.go
+++ b/client_test.go
@@ -2734,6 +2734,30 @@ func TestClientTLSHandshakeTimeout(t *testing.T) {
}
}
+func TestClientConfigureClientFailed(t *testing.T) {
+ t.Parallel()
+
+ c := &Client{
+ ConfigureClient: func(hc *HostClient) error {
+ return fmt.Errorf("failed to configure")
+ },
+ }
+
+ req := Request{}
+ req.SetRequestURI("http://example.com")
+
+ err := c.Do(&req, &Response{})
+ if err == nil {
+ t.Fatal("expected error (failed to configure)")
+ }
+
+ c.ConfigureClient = nil
+ err = c.Do(&req, &Response{})
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+}
+
func TestHostClientMaxConnWaitTimeoutSuccess(t *testing.T) {
t.Parallel()