diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-22 21:30:40 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-22 21:30:40 +0000 |
commit | 95792eb13df32a536a13a5e8b712be06fb059457 (patch) | |
tree | 8c568f35dfa05071fb0e19d00fbb830791950468 /net/http/http_response_headers_unittest.cc | |
parent | f145b5a019b9a082ff0ce94ba94342bbd73f88b2 (diff) | |
download | chromium_src-95792eb13df32a536a13a5e8b712be06fb059457.zip chromium_src-95792eb13df32a536a13a5e8b712be06fb059457.tar.gz chromium_src-95792eb13df32a536a13a5e8b712be06fb059457.tar.bz2 |
Http cache: Return valid Content-Range headers for a byte range request.
BUG=12258
TEST=unittests
Review URL: http://codereview.chromium.org/140015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18961 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_response_headers_unittest.cc')
-rw-r--r-- | net/http/http_response_headers_unittest.cc | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index ec26eb9..ad03107 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -1414,3 +1414,93 @@ TEST(HttpResponseHeadersTest, GetStatusBadStatusLine) { // HTTP/1.0 200 OK. EXPECT_EQ(std::string("OK"), parsed->GetStatusText()); } + +TEST(HttpResponseHeadersTest, AddHeader) { + const struct { + const char* orig_headers; + const char* new_header; + const char* expected_headers; + } tests[] = { + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Cache-control: max-age=10000\n", + + "Content-Length: 450", + + "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Cache-control: max-age=10000\n" + "Content-Length: 450\n" + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Cache-control: max-age=10000 \n", + + "Content-Length: 450 ", + + "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Cache-control: max-age=10000\n" + "Content-Length: 450\n" + }, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { + string orig_headers(tests[i].orig_headers); + HeadersToRaw(&orig_headers); + scoped_refptr<HttpResponseHeaders> parsed = + new HttpResponseHeaders(orig_headers); + + string new_header(tests[i].new_header); + parsed->AddHeader(new_header); + + string resulting_headers; + parsed->GetNormalizedHeaders(&resulting_headers); + EXPECT_EQ(string(tests[i].expected_headers), resulting_headers); + } +} + +TEST(HttpResponseHeadersTest, RemoveHeader) { + const struct { + const char* orig_headers; + const char* to_remove; + const char* expected_headers; + } tests[] = { + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Cache-control: max-age=10000\n" + "Content-Length: 450\n", + + "Content-Length", + + "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Cache-control: max-age=10000\n" + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive \n" + "Content-Length : 450 \n" + "Cache-control: max-age=10000\n", + + "Content-Length", + + "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Cache-control: max-age=10000\n" + }, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { + string orig_headers(tests[i].orig_headers); + HeadersToRaw(&orig_headers); + scoped_refptr<HttpResponseHeaders> parsed = + new HttpResponseHeaders(orig_headers); + + string name(tests[i].to_remove); + parsed->RemoveHeader(name); + + string resulting_headers; + parsed->GetNormalizedHeaders(&resulting_headers); + EXPECT_EQ(string(tests[i].expected_headers), resulting_headers); + } +} |