treq icon indicating copy to clipboard operation
treq copied to clipboard

treq.collect() should close the HTTP transport when the collector function throws an exception

Open itamarst opened this issue 2 years ago • 0 comments

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.

itamarst avatar Jul 15 '22 14:07 itamarst