I couldn't figure out how to separate the pull requests, so there are two sets of changes here.
When a client cancels a streaming response, the iterator can hang around, which causes problems in my application. This change closes an iterator when the response is closed.
Firslty, ChunkedRFile.read() can go into an infinite loop when the default size=None argument is used. Secondly, the remaining message body for chunked requests is not read out like it is for regular requests. The server will then treat leftover chunks as new requests and send 400 Bad Request responses. This change fixes those so chunked requests are handled in the same manner as regular requests.