Part of bzrlib.transport.http.response View In Hierarchy
All accesses should happen sequentially since the acquisition occurs during an http response reception (as sockets can't be seeked, we simulate the seek by just reading and discarding the data).
The access pattern is defined by a set of ranges discovered as reading progress. Only one range is available at a given time, so all accesses should happen with monotonically increasing offsets.
Method | __init__ | Constructor. |
Method | set_range | Change the range mapping |
Method | set_boundary | Define the boundary used in a multi parts message. |
Method | read_boundary | Read the boundary headers defining a new range |
Method | read_range_definition | Read a new range definition in a multi parts message. |
Method | set_range_from_header | Helper to set the new range from its description in the headers |
Method | read | Read size bytes from the current position in the file. |
Method | seek | Undocumented |
Method | tell | Undocumented |
Method | _unquote_boundary | Undocumented |
Method | _checked_read | Read the file checking for short reads. |
Method | _seek_to_next_range | Undocumented |
Parameters | path | File url, for error reports. |
infile | File-like socket set at body start. |
The file should be at the beginning of the body, the first range definition is read and taken into account.
Parse the headers including the empty line following them so that we are ready to read the data itself.
The data read is discarded along the way.
Reading across ranges is not supported. We rely on the underlying http client to clean the socket if we leave bytes unread. This may occur for the final boundary line of a multipart response or for any range request not entirely consumed by the client (due to offset coalescing)
Parameters | size | The number of bytes to read. Leave unspecified or pass -1 to read to EOF. |