diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-21 11:07:19 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-21 11:07:19 +0000 |
commit | b85d14c87edb87b9de3b945f001ef268ae5e9197 (patch) | |
tree | 1318d24e37044c58c41dde2d0550ba76aa301745 /net/http/http_response_headers_unittest.cc | |
parent | b89047e6dd3c90bee61d4043cff3fa487d2c2bbf (diff) | |
download | chromium_src-b85d14c87edb87b9de3b945f001ef268ae5e9197.zip chromium_src-b85d14c87edb87b9de3b945f001ef268ae5e9197.tar.gz chromium_src-b85d14c87edb87b9de3b945f001ef268ae5e9197.tar.bz2 |
Improve merging of header modifications in webRequest.OnHeadersReceived
This CL enables two independent extensions to modify headers of HTTP responses in case they don't conflict (two extension try to edit the same header).
BUG=none
TEST=no
Review URL: http://codereview.chromium.org/8511063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110900 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 | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index 4848510..eec259a 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -1624,6 +1624,72 @@ TEST(HttpResponseHeadersTest, RemoveHeader) { } } +TEST(HttpResponseHeadersTest, RemoveIndividualHeader) { + const struct { + const char* orig_headers; + const char* to_remove_name; + const char* to_remove_value; + 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", + + "450", + + "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", + + "450", + + "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", // Matching name. + + "999", // Mismatching value. + + "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Content-Length: 450\n" + "Cache-control: max-age=10000\n" + }, + + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { + std::string orig_headers(tests[i].orig_headers); + HeadersToRaw(&orig_headers); + scoped_refptr<net::HttpResponseHeaders> parsed( + new net::HttpResponseHeaders(orig_headers)); + + std::string name(tests[i].to_remove_name); + std::string value(tests[i].to_remove_value); + parsed->RemoveHeaderWithValue(name, value); + + std::string resulting_headers; + parsed->GetNormalizedHeaders(&resulting_headers); + EXPECT_EQ(std::string(tests[i].expected_headers), resulting_headers); + } +} + TEST(HttpResponseHeadersTest, ReplaceStatus) { const struct { const char* orig_headers; |