diff --git a/sseclient.py b/sseclient.py index 6d13ad6..4967556 100644 --- a/sseclient.py +++ b/sseclient.py @@ -63,12 +63,12 @@ def _connect(self): def iter_content(self): def generate(): while True: - if hasattr(self.resp.raw, '_fp'): + if hasattr(self.resp.raw, '_fp') and not self.resp.raw.chunked: chunk = self.resp.raw._fp.fp.read1(self.chunk_size) else: - # _fp is not available, this means that we cannot use short - # reads and this will block until the full chunk size is - # actually read + # _fp is not available or we are using chunked encoding + # this means that we cannot use short reads and this will + # block until the full chunk size is actually read chunk = self.resp.raw.read(self.chunk_size) if not chunk: break