| Index: net/http/http_response_headers_unittest.cc
|
| ===================================================================
|
| --- net/http/http_response_headers_unittest.cc (revision 8522)
|
| +++ net/http/http_response_headers_unittest.cc (working copy)
|
| @@ -289,24 +289,29 @@
|
|
|
| TEST(HttpResponseHeadersTest, Persist) {
|
| const struct {
|
| + net::HttpResponseHeaders::PersistOptions options;
|
| const char* raw_headers;
|
| const char* expected_headers;
|
| } tests[] = {
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_ALL,
|
| + "HTTP/1.1 200 OK\n"
|
| "Cache-control:private\n"
|
| "cache-Control:no-store\n",
|
|
|
| "HTTP/1.1 200 OK\n"
|
| "Cache-control: private, no-store\n"
|
| },
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP,
|
| + "HTTP/1.1 200 OK\n"
|
| "connection: keep-alive\n"
|
| "server: blah\n",
|
|
|
| "HTTP/1.1 200 OK\n"
|
| "server: blah\n"
|
| },
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE |
|
| + net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP,
|
| + "HTTP/1.1 200 OK\n"
|
| "fOo: 1\n"
|
| "Foo: 2\n"
|
| "Transfer-Encoding: chunked\n"
|
| @@ -316,7 +321,8 @@
|
| "HTTP/1.1 200 OK\n"
|
| "cache-control: private, no-cache=\"foo\"\n"
|
| },
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
|
| + "HTTP/1.1 200 OK\n"
|
| "Foo: 2\n"
|
| "Cache-Control: private,no-cache=\"foo, bar\"\n"
|
| "bar",
|
| @@ -325,7 +331,8 @@
|
| "Cache-Control: private,no-cache=\"foo, bar\"\n"
|
| },
|
| // ignore bogus no-cache value
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
|
| + "HTTP/1.1 200 OK\n"
|
| "Foo: 2\n"
|
| "Cache-Control: private,no-cache=foo\n",
|
|
|
| @@ -334,7 +341,8 @@
|
| "Cache-Control: private,no-cache=foo\n"
|
| },
|
| // ignore bogus no-cache value
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
|
| + "HTTP/1.1 200 OK\n"
|
| "Foo: 2\n"
|
| "Cache-Control: private, no-cache=\n",
|
|
|
| @@ -343,7 +351,8 @@
|
| "Cache-Control: private, no-cache=\n"
|
| },
|
| // ignore empty no-cache value
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
|
| + "HTTP/1.1 200 OK\n"
|
| "Foo: 2\n"
|
| "Cache-Control: private, no-cache=\"\"\n",
|
|
|
| @@ -352,7 +361,8 @@
|
| "Cache-Control: private, no-cache=\"\"\n"
|
| },
|
| // ignore wrong quotes no-cache value
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
|
| + "HTTP/1.1 200 OK\n"
|
| "Foo: 2\n"
|
| "Cache-Control: private, no-cache=\'foo\'\n",
|
|
|
| @@ -361,7 +371,8 @@
|
| "Cache-Control: private, no-cache=\'foo\'\n"
|
| },
|
| // ignore unterminated quotes no-cache value
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
|
| + "HTTP/1.1 200 OK\n"
|
| "Foo: 2\n"
|
| "Cache-Control: private, no-cache=\"foo\n",
|
|
|
| @@ -370,7 +381,8 @@
|
| "Cache-Control: private, no-cache=\"foo\n"
|
| },
|
| // accept sloppy LWS
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
|
| + "HTTP/1.1 200 OK\n"
|
| "Foo: 2\n"
|
| "Cache-Control: private, no-cache=\" foo\t, bar\"\n",
|
|
|
| @@ -378,7 +390,8 @@
|
| "Cache-Control: private, no-cache=\" foo\t, bar\"\n"
|
| },
|
| // header name appears twice, separated by another header
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_ALL,
|
| + "HTTP/1.1 200 OK\n"
|
| "Foo: 1\n"
|
| "Bar: 2\n"
|
| "Foo: 3\n",
|
| @@ -388,7 +401,8 @@
|
| "Bar: 2\n"
|
| },
|
| // header name appears twice, separated by another header (type 2)
|
| - { "HTTP/1.1 200 OK\n"
|
| + { net::HttpResponseHeaders::PERSIST_ALL,
|
| + "HTTP/1.1 200 OK\n"
|
| "Foo: 1, 3\n"
|
| "Bar: 2\n"
|
| "Foo: 4\n",
|
| @@ -397,6 +411,17 @@
|
| "Foo: 1, 3, 4\n"
|
| "Bar: 2\n"
|
| },
|
| + // Test filtering of cookie headers.
|
| + { net::HttpResponseHeaders::PERSIST_SANS_COOKIES,
|
| + "HTTP/1.1 200 OK\n"
|
| + "Set-Cookie: foo=bar; httponly\n"
|
| + "Set-Cookie: bar=foo\n"
|
| + "Bar: 1\n"
|
| + "Set-Cookie2: bar2=foo2\n",
|
| +
|
| + "HTTP/1.1 200 OK\n"
|
| + "Bar: 1\n"
|
| + },
|
| };
|
|
|
| for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
|
| @@ -406,7 +431,7 @@
|
| new HttpResponseHeaders(headers);
|
|
|
| Pickle pickle;
|
| - parsed1->Persist(&pickle, true);
|
| + parsed1->Persist(&pickle, tests[i].options);
|
|
|
| void* iter = NULL;
|
| scoped_refptr<HttpResponseHeaders> parsed2 =
|
|
|