def generate():
    if hasattr(self.raw, 'stream'):
        try:
            for chunk in self.raw.stream(chunk_size, decode_content=True):
                (yield chunk)
        except ProtocolError as e:
            raise ChunkedEncodingError(e)
        except DecodeError as e:
            raise ContentDecodingError(e)
        except ReadTimeoutError as e:
            raise ConnectionError(e)
    else:
        while True:
            chunk = self.raw.read(chunk_size)
            if (not chunk):
                break
            (yield chunk)
    self._content_consumed = True
def generate():
    if hasattr(self.raw, 'stream'):
        try:
            for chunk in self.raw.stream(chunk_size, decode_content=True):
                (yield chunk)
        except ProtocolError as e:
            raise ChunkedEncodingError(e)
        except DecodeError as e:
            raise ContentDecodingError(e)
        except ReadTimeoutError as e:
            raise ConnectionError(e)
    else:
        while True:
            chunk = self.raw.read(chunk_size)
            if (not chunk):
                break
            (yield chunk)
    self._content_consumed = True