stream2py.sources.http#
HTTP Response streaming reader with no external dependencies#
Classes
|
- class stream2py.sources.http.HTTPResponseReader(url, *, method='GET', headers=None, body='', response_format='bytes', response_read_args=(), encoding='')[source]#
Bases:
SourceReader- close()[source]#
Close and clean up source reader. Will be called when StreamBuffer stops or if an exception is raised during read and append loop.
- property info: dict#
Provides a dict with init kwargs and read status
>>> from pprint import pprint >>> source = HTTPResponseReader('http://zombo.com') >>> pprint(source.info) {'url': 'http://zombo.com', 'n_bytes_read': 0, 'init_kwargs': {'method': 'GET, 'headers': {}, 'body': None, 'response_format': 'bytes'}}
- Returns:
dict
- key(data)[source]#
Returns a slice of the data retrieved.
- Parameters:
data – (start_index, end_index)
- Return type:
- Returns:
Union[str, bytes]