Skip to content

Commit

Permalink
Merge pull request #86 from alinagol/stream_reader
Browse files Browse the repository at this point in the history
Stream reader
  • Loading branch information
antechrestos authored Apr 17, 2020
2 parents 97f334f + fb4e592 commit 75b6159
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main/cloudfoundry_client/rlpgateway/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,10 @@ async def stream_logs(self, app_guid, **kwargs):
if response.status == 204:
yield {}
else:
async for data in response.content:
yield data
buffer = b""
async for data in response.content.iter_chunked(1024):
buffer += data
if b"\n\n" in buffer and buffer.startswith(b"data:"):
log_message = buffer.split(b"\n\n")[0]
buffer = buffer.replace(log_message + b"\n\n", b"")
yield log_message

0 comments on commit 75b6159

Please sign in to comment.