From 43d6ae71a774a5e07595047367689e27af36d9eb Mon Sep 17 00:00:00 2001 From: "hclam@chromium.org" Date: Tue, 16 Jun 2009 23:18:39 +0000 Subject: 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 --- net/http/http_response_headers.cc | 9 +++++++-- net/http/http_response_headers_unittest.cc | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'net/http') 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, -- cgit v1.1