| Index: net/http/http_response_headers_unittest.cc
|
| ===================================================================
|
| --- net/http/http_response_headers_unittest.cc (revision 5616)
|
| +++ net/http/http_response_headers_unittest.cc (working copy)
|
| @@ -290,24 +290,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"
|
| @@ -317,7 +322,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",
|
| @@ -326,7 +332,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",
|
|
|
| @@ -335,7 +342,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",
|
|
|
| @@ -344,7 +352,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",
|
|
|
| @@ -353,7 +362,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",
|
|
|
| @@ -362,7 +372,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",
|
|
|
| @@ -371,7 +382,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",
|
|
|
| @@ -379,7 +391,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",
|
| @@ -389,7 +402,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",
|
| @@ -398,6 +412,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) {
|
| @@ -407,7 +432,7 @@
|
| new HttpResponseHeaders(headers);
|
|
|
| Pickle pickle;
|
| - parsed1->Persist(&pickle, true);
|
| + parsed1->Persist(&pickle, tests[i].options);
|
|
|
| void* iter = NULL;
|
| scoped_refptr<HttpResponseHeaders> parsed2 =
|
|
|