diff options
author | Oleksandr Redko <oleksandr.red+github@gmail.com> | 2023-03-11 18:48:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-11 17:48:33 +0100 |
commit | 7846101dc65ee5e02cea672af4594e3a80048632 (patch) | |
tree | f7c47f6979d427dd4510a1147ebcbc00acd52f29 /client_test.go | |
parent | Fix proxy auth bug (diff) | |
download | fasthttp-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.go | 24 |
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() |