-
Notifications
You must be signed in to change notification settings - Fork 191
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
Allow Range and Content-Range headers to contain any valid range unit #180
Conversation
b10550e
to
6fae1ac
Compare
- Range units other than 'bytes' may be provided as part of a Range or Content-Range header - Updated __repr__() tests for Range and ContentRange to actually test the return value of the repr call (previous test was only asserting that __repr__() returned a 'truthy' value) - Updated Range repr to return a string representation enclosed in angle brackets, matching the style of most other WebOb classes (vs. a string that may be able to be passed to `eval`) - Fixes Pylons#177
6fae1ac
to
bad3c83
Compare
@bertjwregeer - Would you be able to review this PR at your convenience? See #177 for rationale. Thanks! |
I have been really conflicted on whether I wanted to merge this or not to be completely honest. It is not part of any of the standard specs, but at the same time I completely understand the utility and think it would help when I am building my own applications. In reviewing this though, how does this interact with https://github.com/Pylons/webob/blob/master/webob/response.py#L1079? How does this work with sending a conditional response (WebOb conditional response that is). I need more time to understand the implications, and possibly even add a safeguard to the response code that the range unit is bytes. |
@bertjwregeer - The only range unit defined by the spec is "bytes", but the grammar allows for other range units:
The Range Requests memo elaborates:
|
@bertjwregeer - I do see your concern with https://github.com/Pylons/webob/blob/master/webob/response.py#L1079 The conditional app iterates over a range of actual bytes derived from In other words, if the client requests
I don't use the conditional app, so we haven't had an issue with the patch because we handle generating the One approach might be to explicitly disallow anything but "bytes" as a range unit when using the conditional app. |
I am closing this pull request for now. Until WebOb's |
or Content-Range header
the return value of the repr call (previous test was only asserting
that repr() returned a 'truthy' value)
brackets, matching the style of most other WebOb classes
(vs. a string that may be able to be passed to
eval
)