treq
treq copied to clipboard
treq.collect() should close the HTTP transport when the collector function throws an exception
If the collector function throws an exception, that means there is no way to handle remaining body data. In some cases this may actually be a deliberate indication that the response is no good; for example, I implemented a length-constrained variant of treq.content()
, and if the body exceeds that it's indication of a buggy or malicious server.
As such, the only reasonable thing to do in this situation is to close the transport.