facebook/tornado — pull request #686 by omribahumi (2013-02-27 22:20:46+00:00)
Title: Flushing the buffer when calling IOStream.read_until_close()

Ran into this when calling IOStream.read_until_close() after calling
IOStream.read_until("\r\n"), leaving data in the buffer.

When receiving something similar to the following:
```
POST /item HTTP/1.1
Host: example.com
Content-Length: 4

test
```

If you're doing a read_until("\r\n") on the socket, and the entire buffer is received in one chunk, after the callback for read_until() there's still data left in the buffer. When calling read_until_close() with streaming callback, I expect the buffer to be emptied first.

With the current behavior, the socket just hangs (until the client closes it).