Closed lmmx closed 3 years ago
It may be necessary to ‘fake out’ the active range response after it’s been exhausted.
To act like an exhausted partial content request (when in single request mode), you could intercept the active_range_response.read()
and active_range_repsonse.tell()
calls via the RangeStream read
/tell
methods themselves, and where the active_range_response
property would report its RangeResponse object with normal stream capabilities, when in single request mode it could actually create a faked RangeResponse with a dummy read method only in the event that it has been consumed.
There remains the problem of how to stop it reading too many bytes from the stream (and solving that may in fact make the previous suggestion unnecessary/overbaked)
Maybe:
But I don't think either of these will limit the actual stream's ability to return too much of the underlying stream
Maybe seek to the start and call socket.rcv_into
but this returns the number of bytes, not the bytes
The simplest approach would be to just add a window_size
(or window_end
) to the RangeResponse, and if set it would limit the size
read()
into the response as window_size - tell()
, which becomes 0 when the window size is reached, and if not set then the stream is allowed to just naturally self-limit
Resolved, see #32
gives the expected 3 bytes
but
shows you can just keep reading the bytes, there’s no gating of the stream done at all.
b''
. This could be implemented by checking thetell
on the response iterator and making it dependent on the byte range of the active range response (?)