Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

Pete Zaitcev Sergey Schetinin
Pete 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.

Pete 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
Sergey Schetinin maluke merged commit 4bb9375 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 12, 2012
  1. Pete 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
1  tests/test_byterange.py
View
@@ -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
2  webob/byterange.py
View
@@ -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.