summaryrefslogtreecommitdiffstats
path: root/net/http/http_response_headers_unittest.cc
diff options
context:
space:
mode:
authorricea <ricea@chromium.org>2014-10-17 03:49:19 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-17 10:49:43 +0000
commit5db2f4ea9ac85ef4c8221c533e61b26b69c15ab7 (patch)
tree9997076c01c6fbf51077e37b7a1fdf880f90b977 /net/http/http_response_headers_unittest.cc
parente1adb7edbdfa6a76da39a841c8a150bc54cb78fe (diff)
downloadchromium_src-5db2f4ea9ac85ef4c8221c533e61b26b69c15ab7.zip
chromium_src-5db2f4ea9ac85ef4c8221c533e61b26b69c15ab7.tar.gz
chromium_src-5db2f4ea9ac85ef4c8221c533e61b26b69c15ab7.tar.bz2
Make HRH::IsKeepAlive() look past the first header
Up until now, HttpResponseHeaders::IsKeepAlive() only looked at the first value of the Connection header. Since for a WebSocket response a header like Connection: Upgrade, close is valid we should check other values past the first value. BUG=371759 TEST=net_unittests Review URL: https://codereview.chromium.org/640213002 Cr-Commit-Position: refs/heads/master@{#300087}
Diffstat (limited to 'net/http/http_response_headers_unittest.cc')
-rw-r--r--net/http/http_response_headers_unittest.cc85
1 files changed, 85 insertions, 0 deletions
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc
index c0e8598..7e4a6cf 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"
@@ -1640,6 +1641,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> {
@@ -1714,6 +1723,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,