Support short reads of message chunks (fix #8)
Support short reads of message chunks (fix #8)

I ran into an issue a while back where behavior in sseclient regressed
due to a change in how messages were processed; the new behavior
resulted in chunks of data in the response only being processed 1024
bytes (or whatever the chunk size was set to) at a time. For less-busy
streams, this had a significant impact on message delivery time because
messages would get buffered but never processed until the buffer
completely filled. To work around this, it was possible to use a chunk
size of 1.

The problem turned out to be that http.client.HTTPResponse was not
designed to handle short reads, so each read call blocks until the
entire chunk size was read or the end of the file is hit. To fix this,
this change reimplements the iter_content method from requests so
that it accesses the underlying io.BufferedReader from
http.client.HTTPResponse and calls read1 on it, which will not block as
long as data is already buffered.

btubbs/sseclient