diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 23:18:39 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 23:18:39 +0000 |
commit | 43d6ae71a774a5e07595047367689e27af36d9eb (patch) | |
tree | 41baa3f524aac9a3dbe25f6a14f832c0747d325f /net/http | |
parent | a902489dc0a391b0bfa92b8a172aa6369b568436 (diff) | |
download | chromium_src-43d6ae71a774a5e07595047367689e27af36d9eb.zip chromium_src-43d6ae71a774a5e07595047367689e27af36d9eb.tar.gz chromium_src-43d6ae71a774a5e07595047367689e27af36d9eb.tar.bz2 |
Fixing a bug in HttpResponseHeaders.GetContentRange
The code has a glitch in handling LWS near to the "bytes" token.
BUG=14216
Review URL: http://codereview.chromium.org/126229
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_response_headers.cc | 9 | ||||
-rw-r--r-- | net/http/http_response_headers_unittest.cc | 8 |
2 files changed, 14 insertions, 3 deletions
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc index 4038aff..81d2ceb 100644 --- a/net/http/http_response_headers.cc +++ b/net/http/http_response_headers.cc @@ -1000,8 +1000,13 @@ bool HttpResponseHeaders::GetContentRange(int64* first_byte_position, return false; // Invalid header if it doesn't contain "bytes-unit". - if (!LowerCaseEqualsASCII(content_range_spec.begin(), - content_range_spec.begin() + space_position, + std::string::const_iterator content_range_spec_begin = + content_range_spec.begin(); + std::string::const_iterator content_range_spec_end = + content_range_spec.begin() + space_position; + HttpUtil::TrimLWS(&content_range_spec_begin, &content_range_spec_end); + if (!LowerCaseEqualsASCII(content_range_spec_begin, + content_range_spec_end, "bytes")) { return false; } diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index c78c597..da18f11 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -1136,7 +1136,13 @@ TEST(HttpResponseHeaders, GetContentRange) { 50, 51 }, - + { "HTTP/1.1 206 Partial Content\n" + "Content-Range: \tbytes\t\t\t 0\t-\t50\t/\t51\t", + true, + 0, + 50, + 51 + }, { "HTTP/1.1 206 Partial Content\n" "Content-Range: \t bytes \t 0 - 50 / 5 1", false, |