Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC 7233 - Range Requests #978

Closed
magne4000 opened this issue Aug 4, 2016 · 1 comment
Closed

RFC 7233 - Range Requests #978

magne4000 opened this issue Aug 4, 2016 · 1 comment

Comments

@magne4000
Copy link
Contributor

magne4000 commented Aug 4, 2016

I just began to work on implementing RFC 7233 about Range Requests.
Here is the analysis of how I think it should be implemented, followed by open points for which I will need help:

  • wrappers.make_conditional, new signature
def make_conditional(self, request_or_environ):

# becomes

def make_conditional(self, request_or_environ, accept_ranges=False,
                         complete_length=None, ignore_invalid_range_requests=True):

Also, make_conditional can now raise RequestedRangeNotSatisfiable exception.

  • datastructures: new Range.to_content_range_header(self, length) method, to generate Content-Range header value.
  • Modify exceptions.RequestedRangeNotSatisfiableon order to add Content-Range header support
  • http.is_resource_modified new signature

It should be able to take If-Range header into account, but in order to keep current behavior, disabled by default.

def is_resource_modified(environ, etag=None, data=None, last_modified=None):

# becomes

def is_resource_modified(environ, etag=None, data=None, last_modified=None, ignore_if_range=True):

With this implemented, the headers should all be OK, but now comes the question of the data itself.
If those headers are set (through make_conditional method), we must (?) ensure that the data sent by the server actually reflect those headers.

  • Is this the role of Werkzeug, or should this be left to Flask ?
  • If this should be implemented in Werkzeug, can we implement this in a generic way ?
  • If we implement this in a generic way, we will not be able to use things like seek() methods, and thus will make file (through wrap_file method) Range Requests pretty inneficient.

Edit: One answer can be to wrap responses, which are iterable, with a RangeWrapper. Its role would be to yield only the data contained within range. This RangeWrapper should also be able to support underlying streams that are seekable, that way we do not need to read and drop if not necessary.

@untitaker
Copy link
Contributor

Fixed by #977

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants