geemus/excon — pull request #378 by arlimus (2014-04-18 23:41:44+00:00)
Title: return partial results early

When using Excon with a service that streams responses chunk by chunk, it currently blocks and waits until either chunk_size is reached or the full response is received. For some services, it is helpful to get partial results early and act on them (e.g. tickers or long-running requests).

Socket#read will raise an error when the user tries to read before the buffer is ready. This is normal with chunky responses. So when the read jumps into the rescue clause, check if something is already in the buffer. If so, don't wait and retry, but deliver the result first and retry after.

This should solve #350 as well.

Signed-off-by: Dominik Richter