Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: net/http/http_response_headers_unittest.cc

Issue 11264: Drop Set-Cookie from XHR response headers (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_response_headers.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 =
« no previous file with comments | « net/http/http_response_headers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698