Fix a bug where long payloads were read only partially

By repeatedly calling InputStream.read() until the expected number of
bytes has really been received.