Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make the "bytes=" unit case-insensitive in Range header #62

Merged
merged 1 commit into from

2 participants

@zaitcev

I was unable to find any clear guidance in RFC-2616 or elsewhere.
It looks like they simply forgot to mention if token called
"bytes-unit" is case-sensitive or not. Generally fields are
not sensitive, but there are exceptions. Certainly, it is valid
to accept extra units, if we deem "bytes=" and "BYTES=" different.

This patch came about because OpenStack Swift throws an exception
on WebOb 1.2. It worked in WebOb 1.0.8, where we had a code that
invoked .lower() before matching.

@zaitcev zaitcev Make the "bytes=" unit case-insensitive in Range header
I was unable to find any clear guidance in RFC-2616 or elsewhere.
It looks like they simply forgot to mention if token called
"bytes-unit" is case-sensitive or not. Generally fields are
not sensitive, but there are exceptions. Certainly, it is valid
to accept extra units, if we deem "bytes=" and "BYTES=" different.

This patch came about because OpenStack Swift throws an exception
on WebOb 1.2. It worked in WebOb 1.0.8, where we had a code that
invoked .lower() before matching.
6f1ff37
@maluke maluke merged commit 4bb9375 into Pylons:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 12, 2012
  1. @zaitcev

    Make the "bytes=" unit case-insensitive in Range header

    zaitcev authored
    I was unable to find any clear guidance in RFC-2616 or elsewhere.
    It looks like they simply forgot to mention if token called
    "bytes-unit" is case-sensitive or not. Generally fields are
    not sensitive, but there are exceptions. Certainly, it is valid
    to accept extra units, if we deem "bytes=" and "BYTES=" different.
    
    This patch came about because OpenStack Swift throws an exception
    on WebOb 1.2. It worked in WebOb 1.0.8, where we had a code that
    invoked .lower() before matching.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +1 −0  tests/test_byterange.py
  2. +1 −1  webob/byterange.py
View
1  tests/test_byterange.py
@@ -14,6 +14,7 @@ def test_not_satisfiable():
def test_range_parse():
assert isinstance(Range.parse('bytes=0-99'), Range)
+ assert isinstance(Range.parse('BYTES=0-99'), Range)
assert isinstance(Range.parse('bytes = 0-99'), Range)
assert isinstance(Range.parse('bytes=0 - 102'), Range)
assert Range.parse('bytes=10-5') is None
View
2  webob/byterange.py
@@ -2,7 +2,7 @@
__all__ = ['Range', 'ContentRange']
-_rx_range = re.compile('bytes *= *(\d*) *- *(\d*)')
+_rx_range = re.compile('bytes *= *(\d*) *- *(\d*)', flags=re.I)
_rx_content_range = re.compile(r'bytes (?:(\d+)-(\d+)|[*])/(?:(\d+)|[*])')
class Range(object):
Something went wrong with that request. Please try again.