http
http copied to clipboard
Feature request: timeout subclasses
As of this time, all timeouts raise an HTTP::TimeoutError
. I'd like to be able to handle connect timeout errors differently from read or write timeout errors. For example, I want to have a lower connect timeout which I expect to hit occasionally, but also aggressively retry. Because the error happened on connect, I know that no data was sent yet and it's therefore always safe to retry. However, if the error happened on read, I need to take special precautions to see if the server processed the request or not (naturally, the 3rd party API is not idempotent).
I think this could easily be solved, at least for the per operation timeout class. We could have subclasses of HTTP::TimeoutError
that describe the specific type of timeout that was encountered.
Is that something you'd accept? I can take a crack at a PR if so.
This sounds pretty easy to add in a backward-compatible way so long as they share HTTP::TimeoutError
as a parent class
@tarcieri so if I make a PR, should it target a non-master
branch, or would you want to pull that in manually?
I'd suggest making a PR against master