valyala / fasthttp

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
MIT License
21.87k stars 1.76k forks source link

HostClient.DoDeadline() error #1617

Closed YzmjY closed 1 year ago

YzmjY commented 1 year ago

Code:

    c := fasthttp.HostClient{
        Addr: "127.0.0.1:8080",
    }

    req := fasthttp.AcquireRequest()
    req.SetHost("127.0.0.1")
    req.Header.SetMethod("GET")
    rsp := fasthttp.AcquireResponse()
    dd := time.Now().Add(time.Second * 4)
    err := c.DoDeadline(req, rsp, dd)
    if err != nil {
        panic(err)
    }

I found that the timeout parameter doesn't work in this case, cause the config item RetryIf of HostClient will retry and ignore the timeout if the request is GET/HEAD/PUT method.I think it is not as expected , casue I set the timeout, then the DoDeadline should return before the deadline or return a timeout error.

erikdubbelboer commented 1 year ago

Good find, I just pushed a fix.