HTTP.request

I found very strange behaviour of HTTP.request call.

My code looks like this:

try
    result = HTTP.request(method, url, headers, body)
catch e
    something
end

Server returns error, status 501 in my case, but it could be 400, it doesn’t matter. In such case, HTTP.ExceptionRequest.StatusError is caught. That is OK.
Problem is, however, that HTTP.request internally (while code waits for response/return) calls server 5 times, only then it throws that exception.

I am solving it by calling HTTP.request with status_exception=false and then handle status error before catch block, but I still consider it quite weird behaviour.

Any comment/suggestions?

Thank you,

Sounds to me like the retry option is relevant here:

 Retry options

    •  retry = true, retry idempotent requests in case of error.

    •  retries = 4, number of times to retry.

    •  retry_non_idempotent = false, retry non-idempotent requests too. e.g. POST.
1 Like