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

Unified Diff: net/http/http_response_headers_unittest.cc

Issue 640213002: Make HRH::IsKeepAlive() look past the first header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments and Proxy-Connection tests. Created 6 years, 2 months 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
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc
index 098ce73e99aa48a85c42311b3876228ac37567f3..c1fc0a212f8cdd37fa1d7d997853e306e87efa0d 100644
--- a/net/http/http_response_headers_unittest.cc
+++ b/net/http/http_response_headers_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <algorithm>
+#include <iostream>
#include <limits>
#include "base/basictypes.h"
@@ -1582,6 +1583,14 @@ struct KeepAliveTestData {
bool expected_keep_alive;
};
+// Enable GTest to print KeepAliveTestData in an intelligible way if the test
+// fails.
+void PrintTo(const KeepAliveTestData& keep_alive_test_data,
+ std::ostream* os) {
+ *os << "{\"" << keep_alive_test_data.headers << "\", " << std::boolalpha
+ << keep_alive_test_data.expected_keep_alive << "}";
+}
+
class IsKeepAliveTest
: public HttpResponseHeadersTest,
public ::testing::WithParamInterface<KeepAliveTestData> {
@@ -1656,6 +1665,82 @@ const KeepAliveTestData keepalive_tests[] = {
"proxy-connection: keep-alive\n",
true
},
+ { "HTTP/1.1 200 OK\n"
+ "Connection: Upgrade, close\n",
+ false
+ },
+ { "HTTP/1.1 200 OK\n"
+ "Connection: Upgrade, keep-alive\n",
+ true
+ },
+ { "HTTP/1.1 200 OK\n"
+ "Connection: Upgrade\n"
+ "Connection: close\n",
+ false
+ },
+ { "HTTP/1.1 200 OK\n"
+ "Connection: Upgrade\n"
+ "Connection: keep-alive\n",
+ true
+ },
+ { "HTTP/1.1 200 OK\n"
+ "Connection: close, Upgrade\n",
+ false
+ },
+ { "HTTP/1.1 200 OK\n"
+ "Connection: keep-alive, Upgrade\n",
+ true
+ },
+ { "HTTP/1.1 200 OK\n"
+ "Connection: Upgrade\n"
+ "Proxy-Connection: close\n",
+ false
+ },
+ { "HTTP/1.1 200 OK\n"
+ "Connection: Upgrade\n"
+ "Proxy-Connection: keep-alive\n",
+ true
+ },
+ // In situations where the response headers conflict with themselves, use the
+ // first one for backwards-compatibility.
+ { "HTTP/1.1 200 OK\n"
+ "Connection: close\n"
+ "Connection: keep-alive\n",
+ false
+ },
+ { "HTTP/1.1 200 OK\n"
+ "Connection: keep-alive\n"
+ "Connection: close\n",
+ true
+ },
+ { "HTTP/1.0 200 OK\n"
+ "Connection: close\n"
+ "Connection: keep-alive\n",
+ false
+ },
+ { "HTTP/1.0 200 OK\n"
+ "Connection: keep-alive\n"
+ "Connection: close\n",
+ true
+ },
+ // Ignore the Proxy-Connection header if at all possible.
+ { "HTTP/1.0 200 OK\n"
+ "Proxy-Connection: keep-alive\n"
+ "Connection: close\n",
+ false
+ },
+ { "HTTP/1.1 200 OK\n"
+ "Proxy-Connection: close\n"
+ "Connection: keep-alive\n",
+ true
+ },
+ // Older versions of Chrome would have ignored Proxy-Connection in this case,
+ // but it doesn't seem safe.
+ { "HTTP/1.1 200 OK\n"
+ "Proxy-Connection: close\n"
+ "Connection: Transfer-Encoding\n",
+ false
+ },
};
INSTANTIATE_TEST_CASE_P(HttpResponseHeaders,
« 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