summaryrefslogtreecommitdiffstats
path: root/net/http/http_network_transaction_unittest.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-10 17:22:42 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-10 17:22:42 +0000
commita2cb812a4d1fa85fc864b96e70213b72a16cdd1b (patch)
tree7eb2f244e6b0f470a4a0eb0773c3e3bff3d87d78 /net/http/http_network_transaction_unittest.cc
parent79ed860501b01bcc06297aaa1483b0feee72132e (diff)
downloadchromium_src-a2cb812a4d1fa85fc864b96e70213b72a16cdd1b.zip
chromium_src-a2cb812a4d1fa85fc864b96e70213b72a16cdd1b.tar.gz
chromium_src-a2cb812a4d1fa85fc864b96e70213b72a16cdd1b.tar.bz2
SPDY: Alternate-Protocol changes.
Add npn-spdy fallback support. Update protocol from spdy=>npn-spdy. Don't process Alternate-Protocol unless it we enabled NPN. Review URL: http://codereview.chromium.org/763001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41169 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_network_transaction_unittest.cc')
-rw-r--r--net/http/http_network_transaction_unittest.cc76
1 files changed, 66 insertions, 10 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 1cdc818..aa0bca8 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -4253,11 +4253,13 @@ TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) {
}
TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
+ HttpNetworkTransaction::SetNextProtos("needs_to_be_set_for_this_test");
+
SessionDependencies session_deps;
MockRead data_reads[] = {
MockRead("HTTP/1.1 200 OK\r\n"),
- MockRead("Alternate-Protocol: 443:SPDY\r\n\r\n"),
+ MockRead("Alternate-Protocol: 443:npn-spdy\r\n\r\n"),
MockRead("hello world"),
MockRead(false, OK),
};
@@ -4303,8 +4305,10 @@ TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
alternate_protocols.GetAlternateProtocolFor(http_host_port_pair);
HttpAlternateProtocols::PortProtocolPair expected_alternate;
expected_alternate.port = 443;
- expected_alternate.protocol = HttpAlternateProtocols::SPDY;
+ expected_alternate.protocol = HttpAlternateProtocols::NPN_SPDY;
EXPECT_TRUE(expected_alternate.Equals(alternate));
+
+ HttpNetworkTransaction::SetNextProtos("");
}
TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocol) {
@@ -4345,7 +4349,7 @@ TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocol) {
session->mutable_alternate_protocols();
alternate_protocols->SetAlternateProtocolFor(
http_host_port_pair, 1234 /* port is ignored by MockConnect anyway */,
- HttpAlternateProtocols::SPDY);
+ HttpAlternateProtocols::NPN_SPDY);
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
@@ -4374,7 +4378,55 @@ TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocol) {
// response does not indicate SPDY, so we just do standard HTTPS over the port.
// We should add code such that we don't fallback to HTTPS, but fallback to HTTP
// on the original port.
-TEST_F(HttpNetworkTransactionTest, UseAlternateProtocol) {
+// TEST_F(HttpNetworkTransactionTest, UseAlternateProtocol) {
+// SessionDependencies session_deps;
+//
+// HttpRequestInfo request;
+// request.method = "GET";
+// request.url = GURL("http://www.google.com/");
+// request.load_flags = 0;
+//
+// MockRead data_reads[] = {
+// MockRead("HTTP/1.1 200 OK\r\n\r\n"),
+// MockRead("hello world"),
+// MockRead(true, OK),
+// };
+// StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
+// session_deps.socket_factory.AddSocketDataProvider(&data);
+//
+// SSLSocketDataProvider ssl(true, OK);
+// session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
+//
+// TestCompletionCallback callback;
+//
+// scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
+//
+// HostPortPair http_host_port_pair;
+// http_host_port_pair.host = "www.google.com";
+// http_host_port_pair.port = 80;
+// HttpAlternateProtocols* alternate_protocols =
+// session->mutable_alternate_protocols();
+// alternate_protocols->SetAlternateProtocolFor(
+// http_host_port_pair, 1234 /* port is ignored */,
+// HttpAlternateProtocols::NPN_SPDY);
+//
+// scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
+//
+// int rv = trans->Start(&request, &callback, NULL);
+// EXPECT_EQ(ERR_IO_PENDING, rv);
+// EXPECT_EQ(OK, callback.WaitForResult());
+//
+// const HttpResponseInfo* response = trans->GetResponseInfo();
+// ASSERT_TRUE(response != NULL);
+// ASSERT_TRUE(response->headers != NULL);
+// EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
+//
+// std::string response_data;
+// ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
+// EXPECT_EQ("hello world", response_data);
+// }
+
+TEST_F(HttpNetworkTransactionTest, FailNpnSpdyAndFallback) {
SessionDependencies session_deps;
HttpRequestInfo request;
@@ -4382,16 +4434,20 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocol) {
request.url = GURL("http://www.google.com/");
request.load_flags = 0;
+ StaticSocketDataProvider first_tcp_connect;
+ session_deps.socket_factory.AddSocketDataProvider(&first_tcp_connect);
+
+ SSLSocketDataProvider ssl(true, OK);
+ session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
+
MockRead data_reads[] = {
MockRead("HTTP/1.1 200 OK\r\n\r\n"),
MockRead("hello world"),
MockRead(true, OK),
};
- StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
- session_deps.socket_factory.AddSocketDataProvider(&data);
-
- SSLSocketDataProvider ssl(true, OK);
- session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
+ StaticSocketDataProvider fallback_data(
+ data_reads, arraysize(data_reads), NULL, 0);
+ session_deps.socket_factory.AddSocketDataProvider(&fallback_data);
TestCompletionCallback callback;
@@ -4404,7 +4460,7 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocol) {
session->mutable_alternate_protocols();
alternate_protocols->SetAlternateProtocolFor(
http_host_port_pair, 1234 /* port is ignored */,
- HttpAlternateProtocols::SPDY);
+ HttpAlternateProtocols::NPN_SPDY);
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));