My server does external requests and I'd like to limit the damage a failing request can do. I'm looking to cancel the request in these situations:
- the total time of the request is over a certain limit (even if data is still arriving)
- the total received size exceeds some limit (I need to cancel prior to accepting more data)
- the transfer speed drops below some level (though I can live without this one if a total time limit can be provided)
Note I am not looking for the timeout
parameter in requests, as this is a timeout only for inactivity. I'm unable to find anything to do with a total timeout, or a way to limit the total size. One example shows a maxsize
parameter on HTTPAdapter
but that is not documented.
How can I achieve these requirements using requests
?