parnurzeal / gorequest

GoRequest -- Simplified HTTP client ( inspired by nodejs SuperAgent )
http://parnurzeal.github.io/gorequest/
MIT License
3.44k stars 414 forks source link

Retry with self-defined http response status code #268

Closed ahojcn closed 2 years ago

ahojcn commented 2 years ago

I use self-defined http status code 555 to represents that the request is current limited, and i want to retry 3 times when response status code is 555 It doesn't seem to work.

gorequest.New().Get("127.0.0.1:8080/test").Retry(3, time.Duration(10)*time.Second, 555)

errs looks like:

[StatusCode '555' doesn't exist in http package]
        for _, code := range statusCode {
        statusText := http.StatusText(code)
        if len(statusText) == 0 {
            s.Errors = append(s.Errors, errors.New("StatusCode '"+strconv.Itoa(code)+"' doesn't exist in http package"))
        }
    }

What should I do in this situation?

Thank you very much. :)

wklken commented 2 years ago

I think you should fork gorequest, and remove the statusText check.


My fork and release have some bugfixes and changes wklken/gorequest/releases

ahojcn commented 2 years ago

I think you should fork gorequest, and remove the statusText check.

My fork and release have some bugfixes and changes wklken/gorequest/releases

Thank you!