| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 1675 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 1676 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 1676 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
| 1677 session_deps.net_log = log.bound().net_log(); | 1677 session_deps.net_log = log.bound().net_log(); |
| 1678 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1678 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1679 | 1679 |
| 1680 // Since we have proxy, should try to establish tunnel. | 1680 // Since we have proxy, should try to establish tunnel. |
| 1681 MockWrite data_writes1[] = { | 1681 MockWrite data_writes1[] = { |
| 1682 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1682 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1683 "Host: www.google.com\r\n" | 1683 "Host: www.google.com\r\n" |
| 1684 "Proxy-Connection: keep-alive\r\n\r\n"), | 1684 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 1685 }; | |
| 1686 | 1685 |
| 1687 MockWrite data_writes2[] = { | |
| 1688 // After calling trans->RestartWithAuth(), this is the request we should | 1686 // After calling trans->RestartWithAuth(), this is the request we should |
| 1689 // be issuing -- the final header line contains the credentials. | 1687 // be issuing -- the final header line contains the credentials. |
| 1690 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1688 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1691 "Host: www.google.com\r\n" | 1689 "Host: www.google.com\r\n" |
| 1692 "Proxy-Connection: keep-alive\r\n" | 1690 "Proxy-Connection: keep-alive\r\n" |
| 1693 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 1691 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
| 1694 | 1692 |
| 1695 MockWrite("GET / HTTP/1.1\r\n" | 1693 MockWrite("GET / HTTP/1.1\r\n" |
| 1696 "Host: www.google.com\r\n" | 1694 "Host: www.google.com\r\n" |
| 1697 "Connection: keep-alive\r\n\r\n"), | 1695 "Connection: keep-alive\r\n\r\n"), |
| 1698 }; | 1696 }; |
| 1699 | 1697 |
| 1700 // The proxy responds to the connect with a 407, using a persistent | 1698 // The proxy responds to the connect with a 407, using a persistent |
| 1701 // connection. | 1699 // connection. |
| 1702 MockRead data_reads1[] = { | 1700 MockRead data_reads1[] = { |
| 1703 // No credentials. | 1701 // No credentials. |
| 1704 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 1702 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
| 1705 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 1703 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 1706 MockRead("Proxy-Connection: close\r\n\r\n"), | 1704 MockRead("Proxy-Connection: close\r\n\r\n"), |
| 1707 }; | |
| 1708 | 1705 |
| 1709 MockRead data_reads2[] = { | |
| 1710 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), | 1706 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), |
| 1711 | 1707 |
| 1712 MockRead("HTTP/1.1 200 OK\r\n"), | 1708 MockRead("HTTP/1.1 200 OK\r\n"), |
| 1713 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 1709 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 1714 MockRead("Content-Length: 5\r\n\r\n"), | 1710 MockRead("Content-Length: 5\r\n\r\n"), |
| 1715 MockRead(false, "hello"), | 1711 MockRead(false, "hello"), |
| 1716 }; | 1712 }; |
| 1717 | 1713 |
| 1718 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1714 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1719 data_writes1, arraysize(data_writes1)); | 1715 data_writes1, arraysize(data_writes1)); |
| 1720 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | |
| 1721 data_writes2, arraysize(data_writes2)); | |
| 1722 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1716 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1723 session_deps.socket_factory.AddSocketDataProvider(&data2); | |
| 1724 SSLSocketDataProvider ssl(true, OK); | 1717 SSLSocketDataProvider ssl(true, OK); |
| 1725 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 1718 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 1726 | 1719 |
| 1727 TestOldCompletionCallback callback1; | 1720 TestOldCompletionCallback callback1; |
| 1728 | 1721 |
| 1729 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1722 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1730 | 1723 |
| 1731 int rv = trans->Start(&request, &callback1, log.bound()); | 1724 int rv = trans->Start(&request, &callback1, log.bound()); |
| 1732 EXPECT_EQ(ERR_IO_PENDING, rv); | 1725 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1733 | 1726 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1926 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 1919 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 1927 | 1920 |
| 1928 std::string response_data; | 1921 std::string response_data; |
| 1929 rv = ReadTransaction(trans.get(), &response_data); | 1922 rv = ReadTransaction(trans.get(), &response_data); |
| 1930 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 1923 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
| 1931 | 1924 |
| 1932 // Flush the idle socket before the HttpNetworkTransaction goes out of scope. | 1925 // Flush the idle socket before the HttpNetworkTransaction goes out of scope. |
| 1933 session->CloseAllConnections(); | 1926 session->CloseAllConnections(); |
| 1934 } | 1927 } |
| 1935 | 1928 |
| 1936 // Test the request-challenge-retry sequence for basic auth, over a connection | |
| 1937 // that requires a restart when setting up an SSL tunnel. | |
| 1938 TEST_F(HttpNetworkTransactionTest, BasicAuthHttpsProxyNoKeepAlive) { | |
| 1939 HttpRequestInfo request; | |
| 1940 request.method = "GET"; | |
| 1941 request.url = GURL("https://www.google.com/"); | |
| 1942 // when the no authentication data flag is set. | |
| 1943 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | |
| 1944 | |
| 1945 // Configure against https proxy server "myproxy:70". | |
| 1946 SessionDependencies session_deps( | |
| 1947 ProxyService::CreateFixed("https://myproxy:70")); | |
| 1948 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | |
| 1949 session_deps.net_log = log.bound().net_log(); | |
| 1950 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | |
| 1951 | |
| 1952 // Since we have proxy, should try to establish tunnel. | |
| 1953 MockWrite data_writes1[] = { | |
| 1954 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | |
| 1955 "Host: www.google.com\r\n" | |
| 1956 "Proxy-Connection: keep-alive\r\n\r\n"), | |
| 1957 }; | |
| 1958 | |
| 1959 MockWrite data_writes2[] = { | |
| 1960 // After calling trans->RestartWithAuth(), this is the request we should | |
| 1961 // be issuing -- the final header line contains the credentials. | |
| 1962 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | |
| 1963 "Host: www.google.com\r\n" | |
| 1964 "Proxy-Connection: keep-alive\r\n" | |
| 1965 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | |
| 1966 | |
| 1967 MockWrite("GET / HTTP/1.1\r\n" | |
| 1968 "Host: www.google.com\r\n" | |
| 1969 "Connection: keep-alive\r\n\r\n"), | |
| 1970 }; | |
| 1971 | |
| 1972 // The proxy responds to the connect with a 407, using a persistent | |
| 1973 // connection. | |
| 1974 MockRead data_reads1[] = { | |
| 1975 // No credentials. | |
| 1976 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | |
| 1977 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | |
| 1978 MockRead("Proxy-Connection: close\r\n\r\n"), | |
| 1979 }; | |
| 1980 | |
| 1981 MockRead data_reads2[] = { | |
| 1982 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), | |
| 1983 | |
| 1984 MockRead("HTTP/1.1 200 OK\r\n"), | |
| 1985 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | |
| 1986 MockRead("Content-Length: 5\r\n\r\n"), | |
| 1987 MockRead(false, "hello"), | |
| 1988 }; | |
| 1989 | |
| 1990 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | |
| 1991 data_writes1, arraysize(data_writes1)); | |
| 1992 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | |
| 1993 data_writes2, arraysize(data_writes2)); | |
| 1994 session_deps.socket_factory.AddSocketDataProvider(&data1); | |
| 1995 session_deps.socket_factory.AddSocketDataProvider(&data2); | |
| 1996 SSLSocketDataProvider proxy(true, OK); | |
| 1997 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy); | |
| 1998 SSLSocketDataProvider proxy2(true, OK); | |
| 1999 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy2); | |
| 2000 SSLSocketDataProvider server(true, OK); | |
| 2001 session_deps.socket_factory.AddSSLSocketDataProvider(&server); | |
| 2002 | |
| 2003 TestOldCompletionCallback callback1; | |
| 2004 | |
| 2005 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | |
| 2006 | |
| 2007 int rv = trans->Start(&request, &callback1, log.bound()); | |
| 2008 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 2009 | |
| 2010 rv = callback1.WaitForResult(); | |
| 2011 EXPECT_EQ(OK, rv); | |
| 2012 net::CapturingNetLog::EntryList entries; | |
| 2013 log.GetEntries(&entries); | |
| 2014 size_t pos = ExpectLogContainsSomewhere( | |
| 2015 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | |
| 2016 NetLog::PHASE_NONE); | |
| 2017 ExpectLogContainsSomewhere( | |
| 2018 entries, pos, | |
| 2019 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | |
| 2020 NetLog::PHASE_NONE); | |
| 2021 | |
| 2022 const HttpResponseInfo* response = trans->GetResponseInfo(); | |
| 2023 ASSERT_TRUE(response != NULL); | |
| 2024 ASSERT_FALSE(response->headers == NULL); | |
| 2025 EXPECT_EQ(407, response->headers->response_code()); | |
| 2026 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | |
| 2027 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | |
| 2028 | |
| 2029 TestOldCompletionCallback callback2; | |
| 2030 | |
| 2031 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | |
| 2032 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 2033 | |
| 2034 rv = callback2.WaitForResult(); | |
| 2035 EXPECT_EQ(OK, rv); | |
| 2036 | |
| 2037 response = trans->GetResponseInfo(); | |
| 2038 ASSERT_TRUE(response != NULL); | |
| 2039 | |
| 2040 EXPECT_TRUE(response->headers->IsKeepAlive()); | |
| 2041 EXPECT_EQ(200, response->headers->response_code()); | |
| 2042 EXPECT_EQ(5, response->headers->GetContentLength()); | |
| 2043 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | |
| 2044 | |
| 2045 // The password prompt info should not be set. | |
| 2046 EXPECT_TRUE(response->auth_challenge.get() == NULL); | |
| 2047 | |
| 2048 trans.reset(); | |
| 2049 session->CloseAllConnections(); | |
| 2050 } | |
| 2051 | |
| 2052 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | |
| 2053 // proxy connection, when setting up an SSL tunnel. | |
| 2054 TEST_F(HttpNetworkTransactionTest, BasicAuthHttpsProxyKeepAlive) { | |
| 2055 HttpRequestInfo request; | |
| 2056 request.method = "GET"; | |
| 2057 request.url = GURL("https://www.google.com/"); | |
| 2058 // Ensure that proxy authentication is attempted even | |
| 2059 // when the no authentication data flag is set. | |
| 2060 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | |
| 2061 | |
| 2062 // Configure against https proxy server "myproxy:70". | |
| 2063 SessionDependencies session_deps( | |
| 2064 ProxyService::CreateFixed("https://myproxy:70")); | |
| 2065 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | |
| 2066 session_deps.net_log = log.bound().net_log(); | |
| 2067 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | |
| 2068 | |
| 2069 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | |
| 2070 | |
| 2071 // Since we have proxy, should try to establish tunnel. | |
| 2072 MockWrite data_writes1[] = { | |
| 2073 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | |
| 2074 "Host: www.google.com\r\n" | |
| 2075 "Proxy-Connection: keep-alive\r\n\r\n"), | |
| 2076 | |
| 2077 // After calling trans->RestartWithAuth(), this is the request we should | |
| 2078 // be issuing -- the final header line contains the credentials. | |
| 2079 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | |
| 2080 "Host: www.google.com\r\n" | |
| 2081 "Proxy-Connection: keep-alive\r\n" | |
| 2082 "Proxy-Authorization: Basic Zm9vOmJheg==\r\n\r\n"), | |
| 2083 }; | |
| 2084 | |
| 2085 // The proxy responds to the connect with a 407, using a persistent | |
| 2086 // connection. | |
| 2087 MockRead data_reads1[] = { | |
| 2088 // No credentials. | |
| 2089 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | |
| 2090 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | |
| 2091 MockRead("Content-Length: 10\r\n\r\n"), | |
| 2092 MockRead("0123456789"), | |
| 2093 | |
| 2094 // Wrong credentials (wrong password). | |
| 2095 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | |
| 2096 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | |
| 2097 MockRead("Content-Length: 10\r\n\r\n"), | |
| 2098 // No response body because the test stops reading here. | |
| 2099 MockRead(false, ERR_UNEXPECTED), // Should not be reached. | |
| 2100 }; | |
| 2101 | |
| 2102 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | |
| 2103 data_writes1, arraysize(data_writes1)); | |
| 2104 session_deps.socket_factory.AddSocketDataProvider(&data1); | |
| 2105 SSLSocketDataProvider ssl(true, OK); | |
| 2106 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | |
| 2107 | |
| 2108 TestOldCompletionCallback callback1; | |
| 2109 | |
| 2110 int rv = trans->Start(&request, &callback1, log.bound()); | |
| 2111 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 2112 | |
| 2113 rv = callback1.WaitForResult(); | |
| 2114 EXPECT_EQ(OK, rv); | |
| 2115 net::CapturingNetLog::EntryList entries; | |
| 2116 log.GetEntries(&entries); | |
| 2117 size_t pos = ExpectLogContainsSomewhere( | |
| 2118 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | |
| 2119 NetLog::PHASE_NONE); | |
| 2120 ExpectLogContainsSomewhere( | |
| 2121 entries, pos, | |
| 2122 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | |
| 2123 NetLog::PHASE_NONE); | |
| 2124 | |
| 2125 const HttpResponseInfo* response = trans->GetResponseInfo(); | |
| 2126 ASSERT_TRUE(response != NULL); | |
| 2127 ASSERT_FALSE(response->headers == NULL); | |
| 2128 EXPECT_TRUE(response->headers->IsKeepAlive()); | |
| 2129 EXPECT_EQ(407, response->headers->response_code()); | |
| 2130 EXPECT_EQ(10, response->headers->GetContentLength()); | |
| 2131 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | |
| 2132 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | |
| 2133 | |
| 2134 TestOldCompletionCallback callback2; | |
| 2135 | |
| 2136 // Wrong password (should be "bar"). | |
| 2137 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBaz), &callback2); | |
| 2138 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 2139 | |
| 2140 rv = callback2.WaitForResult(); | |
| 2141 EXPECT_EQ(OK, rv); | |
| 2142 | |
| 2143 response = trans->GetResponseInfo(); | |
| 2144 ASSERT_TRUE(response != NULL); | |
| 2145 ASSERT_FALSE(response->headers == NULL); | |
| 2146 EXPECT_TRUE(response->headers->IsKeepAlive()); | |
| 2147 EXPECT_EQ(407, response->headers->response_code()); | |
| 2148 EXPECT_EQ(10, response->headers->GetContentLength()); | |
| 2149 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | |
| 2150 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | |
| 2151 | |
| 2152 // Flush the idle socket before the NetLog and HttpNetworkTransaction go | |
| 2153 // out of scope. | |
| 2154 session->CloseAllConnections(); | |
| 2155 } | |
| 2156 | |
| 2157 // Test the request-challenge-retry sequence for basic auth, through | |
| 2158 // a SPDY proxy over a single SPDY session. | |
| 2159 TEST_F(HttpNetworkTransactionTest, BasicAuthSpdyProxy) { | |
| 2160 HttpRequestInfo request; | |
| 2161 request.method = "GET"; | |
| 2162 request.url = GURL("https://www.google.com/"); | |
| 2163 // when the no authentication data flag is set. | |
| 2164 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | |
| 2165 | |
| 2166 // Configure against https proxy server "myproxy:70". | |
| 2167 SessionDependencies session_deps( | |
| 2168 ProxyService::CreateFixed("https://myproxy:70")); | |
| 2169 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | |
| 2170 session_deps.net_log = log.bound().net_log(); | |
| 2171 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | |
| 2172 | |
| 2173 // Since we have proxy, should try to establish tunnel. | |
| 2174 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyConnect(NULL, 0, 1)); | |
| 2175 scoped_ptr<spdy::SpdyFrame> rst(ConstructSpdyRstStream(1, spdy::CANCEL)); | |
| 2176 | |
| 2177 // After calling trans->RestartWithAuth(), this is the request we should | |
| 2178 // be issuing -- the final header line contains the credentials. | |
| 2179 const char* const kAuthCredentials[] = { | |
| 2180 "proxy-authorization", "Basic Zm9vOmJhcg==", | |
| 2181 }; | |
| 2182 scoped_ptr<spdy::SpdyFrame> connect2( | |
| 2183 ConstructSpdyConnect(kAuthCredentials, arraysize(kAuthCredentials)/2, 3)); | |
| 2184 // fetch https://www.google.com/ via HTTP | |
| 2185 const char get[] = "GET / HTTP/1.1\r\n" | |
| 2186 "Host: www.google.com\r\n" | |
| 2187 "Connection: keep-alive\r\n\r\n"; | |
| 2188 scoped_ptr<spdy::SpdyFrame> wrapped_get( | |
| 2189 ConstructSpdyBodyFrame(3, get, strlen(get), false)); | |
| 2190 | |
| 2191 MockWrite spdy_writes[] = { | |
| 2192 CreateMockWrite(*req, 0, true), | |
| 2193 CreateMockWrite(*rst, 2, true), | |
| 2194 CreateMockWrite(*connect2, 3), | |
| 2195 CreateMockWrite(*wrapped_get, 5) | |
| 2196 }; | |
| 2197 | |
| 2198 // The proxy responds to the connect with a 407, using a persistent | |
| 2199 // connection. | |
| 2200 const char* const kAuthChallenge[] = { | |
| 2201 "status", "407 Proxy Authentication Required", | |
| 2202 "version", "HTTP/1.1", | |
| 2203 "proxy-authenticate", "Basic realm=\"MyRealm1\"", | |
| 2204 }; | |
| 2205 | |
| 2206 scoped_ptr<spdy::SpdyFrame> conn_auth_resp( | |
| 2207 ConstructSpdyControlFrame(NULL, | |
| 2208 0, | |
| 2209 false, | |
| 2210 1, | |
| 2211 LOWEST, | |
| 2212 spdy::SYN_REPLY, | |
| 2213 spdy::CONTROL_FLAG_NONE, | |
| 2214 kAuthChallenge, | |
| 2215 arraysize(kAuthChallenge))); | |
| 2216 | |
| 2217 scoped_ptr<spdy::SpdyFrame> conn_resp(ConstructSpdyGetSynReply(NULL, 0, 3)); | |
| 2218 const char resp[] = "HTTP/1.1 200 OK\r\n" | |
| 2219 "Content-Length: 5\r\n\r\n"; | |
| 2220 | |
| 2221 scoped_ptr<spdy::SpdyFrame> wrapped_get_resp( | |
| 2222 ConstructSpdyBodyFrame(3, resp, strlen(resp), false)); | |
| 2223 scoped_ptr<spdy::SpdyFrame> wrapped_body( | |
| 2224 ConstructSpdyBodyFrame(3, "hello", 10, false)); | |
| 2225 MockRead spdy_reads[] = { | |
| 2226 CreateMockRead(*conn_auth_resp, 1, true), | |
| 2227 CreateMockRead(*conn_resp, 4, true), | |
| 2228 CreateMockRead(*wrapped_get_resp, 5, true), | |
| 2229 CreateMockRead(*wrapped_body, 6, true), | |
| 2230 MockRead(false, ERR_IO_PENDING), | |
| 2231 }; | |
| 2232 | |
| 2233 scoped_refptr<OrderedSocketData> spdy_data( | |
| 2234 new OrderedSocketData( | |
| 2235 spdy_reads, arraysize(spdy_reads), | |
| 2236 spdy_writes, arraysize(spdy_writes))); | |
| 2237 session_deps.socket_factory.AddSocketDataProvider(spdy_data); | |
| 2238 // Negotiate SPDY to the proxy | |
| 2239 SSLSocketDataProvider proxy(true, OK); | |
| 2240 proxy.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | |
| 2241 proxy.next_proto = "spdy/2"; | |
| 2242 proxy.was_npn_negotiated = true; | |
| 2243 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy); | |
| 2244 // Vanilla SSL to the server | |
| 2245 SSLSocketDataProvider server(true, OK); | |
| 2246 session_deps.socket_factory.AddSSLSocketDataProvider(&server); | |
| 2247 | |
| 2248 TestOldCompletionCallback callback1; | |
| 2249 | |
| 2250 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | |
| 2251 | |
| 2252 int rv = trans->Start(&request, &callback1, log.bound()); | |
| 2253 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 2254 | |
| 2255 rv = callback1.WaitForResult(); | |
| 2256 EXPECT_EQ(OK, rv); | |
| 2257 net::CapturingNetLog::EntryList entries; | |
| 2258 log.GetEntries(&entries); | |
| 2259 size_t pos = ExpectLogContainsSomewhere( | |
| 2260 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | |
| 2261 NetLog::PHASE_NONE); | |
| 2262 ExpectLogContainsSomewhere( | |
| 2263 entries, pos, | |
| 2264 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | |
| 2265 NetLog::PHASE_NONE); | |
| 2266 | |
| 2267 const HttpResponseInfo* response = trans->GetResponseInfo(); | |
| 2268 ASSERT_TRUE(response != NULL); | |
| 2269 ASSERT_FALSE(response->headers == NULL); | |
| 2270 EXPECT_EQ(407, response->headers->response_code()); | |
| 2271 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | |
| 2272 EXPECT_TRUE(response->auth_challenge.get() != NULL); | |
| 2273 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | |
| 2274 | |
| 2275 TestOldCompletionCallback callback2; | |
| 2276 | |
| 2277 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | |
| 2278 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 2279 | |
| 2280 rv = callback2.WaitForResult(); | |
| 2281 EXPECT_EQ(OK, rv); | |
| 2282 | |
| 2283 response = trans->GetResponseInfo(); | |
| 2284 ASSERT_TRUE(response != NULL); | |
| 2285 | |
| 2286 EXPECT_TRUE(response->headers->IsKeepAlive()); | |
| 2287 EXPECT_EQ(200, response->headers->response_code()); | |
| 2288 EXPECT_EQ(5, response->headers->GetContentLength()); | |
| 2289 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | |
| 2290 | |
| 2291 // The password prompt info should not be set. | |
| 2292 EXPECT_TRUE(response->auth_challenge.get() == NULL); | |
| 2293 | |
| 2294 trans.reset(); | |
| 2295 session->CloseAllConnections(); | |
| 2296 } | |
| 2297 | |
| 2298 // Test when a server (non-proxy) returns a 407 (proxy-authenticate). | 1929 // Test when a server (non-proxy) returns a 407 (proxy-authenticate). |
| 2299 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH. | 1930 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH. |
| 2300 TEST_F(HttpNetworkTransactionTest, UnexpectedProxyAuth) { | 1931 TEST_F(HttpNetworkTransactionTest, UnexpectedProxyAuth) { |
| 2301 HttpRequestInfo request; | 1932 HttpRequestInfo request; |
| 2302 request.method = "GET"; | 1933 request.method = "GET"; |
| 2303 request.url = GURL("http://www.google.com/"); | 1934 request.url = GURL("http://www.google.com/"); |
| 2304 request.load_flags = 0; | 1935 request.load_flags = 0; |
| 2305 | 1936 |
| 2306 // We are using a DIRECT connection (i.e. no proxy) for this session. | 1937 // We are using a DIRECT connection (i.e. no proxy) for this session. |
| 2307 SessionDependencies session_deps; | 1938 SessionDependencies session_deps; |
| (...skipping 5382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7690 } | 7321 } |
| 7691 | 7322 |
| 7692 // GenerateAuthToken is a mighty big test. | 7323 // GenerateAuthToken is a mighty big test. |
| 7693 // It tests all permutation of GenerateAuthToken behavior: | 7324 // It tests all permutation of GenerateAuthToken behavior: |
| 7694 // - Synchronous and Asynchronous completion. | 7325 // - Synchronous and Asynchronous completion. |
| 7695 // - OK or error on completion. | 7326 // - OK or error on completion. |
| 7696 // - Direct connection, non-authenticating proxy, and authenticating proxy. | 7327 // - Direct connection, non-authenticating proxy, and authenticating proxy. |
| 7697 // - HTTP or HTTPS backend (to include proxy tunneling). | 7328 // - HTTP or HTTPS backend (to include proxy tunneling). |
| 7698 // - Non-authenticating and authenticating backend. | 7329 // - Non-authenticating and authenticating backend. |
| 7699 // | 7330 // |
| 7700 // In all, there are 44 reasonable permutations (for example, if there are | 7331 // In all, there are 44 reasonable permuations (for example, if there are |
| 7701 // problems generating an auth token for an authenticating proxy, we don't | 7332 // problems generating an auth token for an authenticating proxy, we don't |
| 7702 // need to test all permutations of the backend server). | 7333 // need to test all permutations of the backend server). |
| 7703 // | 7334 // |
| 7704 // The test proceeds by going over each of the configuration cases, and | 7335 // The test proceeds by going over each of the configuration cases, and |
| 7705 // potentially running up to three rounds in each of the tests. The TestConfig | 7336 // potentially running up to three rounds in each of the tests. The TestConfig |
| 7706 // specifies both the configuration for the test as well as the expectations | 7337 // specifies both the configuration for the test as well as the expectations |
| 7707 // for the results. | 7338 // for the results. |
| 7708 TEST_F(HttpNetworkTransactionTest, GenerateAuthToken) { | 7339 TEST_F(HttpNetworkTransactionTest, GenerateAuthToken) { |
| 7709 static const char kServer[] = "http://www.example.com"; | 7340 static const char kServer[] = "http://www.example.com"; |
| 7710 static const char kSecureServer[] = "https://www.example.com"; | 7341 static const char kSecureServer[] = "https://www.example.com"; |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8510 TEST_F(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { | 8141 TEST_F(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { |
| 8511 // This test ensures that the URL passed into the proxy is upgraded | 8142 // This test ensures that the URL passed into the proxy is upgraded |
| 8512 // to https when doing an Alternate Protocol upgrade. | 8143 // to https when doing an Alternate Protocol upgrade. |
| 8513 HttpStreamFactory::set_use_alternate_protocols(true); | 8144 HttpStreamFactory::set_use_alternate_protocols(true); |
| 8514 HttpStreamFactory::set_next_protos( | 8145 HttpStreamFactory::set_next_protos( |
| 8515 MakeNextProtos("http/1.1", "http1.1", "spdy/2", "spdy", NULL)); | 8146 MakeNextProtos("http/1.1", "http1.1", "spdy/2", "spdy", NULL)); |
| 8516 | 8147 |
| 8517 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8148 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8518 HttpAuthHandlerMock::Factory* auth_factory = | 8149 HttpAuthHandlerMock::Factory* auth_factory = |
| 8519 new HttpAuthHandlerMock::Factory(); | 8150 new HttpAuthHandlerMock::Factory(); |
| 8520 HttpAuthHandlerMock* auth_handler1 = new HttpAuthHandlerMock(); | 8151 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); |
| 8521 auth_factory->AddMockHandler(auth_handler1, HttpAuth::AUTH_PROXY); | 8152 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); |
| 8522 HttpAuthHandlerMock* auth_handler2 = new HttpAuthHandlerMock(); | |
| 8523 auth_factory->AddMockHandler(auth_handler2, HttpAuth::AUTH_PROXY); | |
| 8524 auth_factory->set_do_init_from_challenge(true); | 8153 auth_factory->set_do_init_from_challenge(true); |
| 8525 session_deps.http_auth_handler_factory.reset(auth_factory); | 8154 session_deps.http_auth_handler_factory.reset(auth_factory); |
| 8526 | 8155 |
| 8527 HttpRequestInfo request; | 8156 HttpRequestInfo request; |
| 8528 request.method = "GET"; | 8157 request.method = "GET"; |
| 8529 request.url = GURL("http://www.google.com"); | 8158 request.url = GURL("http://www.google.com"); |
| 8530 request.load_flags = 0; | 8159 request.load_flags = 0; |
| 8531 | 8160 |
| 8532 // First round goes unauthenticated through the proxy. | 8161 // First round goes unauthenticated through the proxy. |
| 8533 MockWrite data_writes_1[] = { | 8162 MockWrite data_writes_1[] = { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8545 }; | 8174 }; |
| 8546 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), | 8175 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), |
| 8547 data_writes_1, arraysize(data_writes_1)); | 8176 data_writes_1, arraysize(data_writes_1)); |
| 8548 | 8177 |
| 8549 // Second round tries to tunnel to www.google.com due to the | 8178 // Second round tries to tunnel to www.google.com due to the |
| 8550 // Alternate-Protocol announcement in the first round. It fails due | 8179 // Alternate-Protocol announcement in the first round. It fails due |
| 8551 // to a proxy authentication challenge. | 8180 // to a proxy authentication challenge. |
| 8552 // After the failure, a tunnel is established to www.google.com using | 8181 // After the failure, a tunnel is established to www.google.com using |
| 8553 // Proxy-Authorization headers. There is then a SPDY request round. | 8182 // Proxy-Authorization headers. There is then a SPDY request round. |
| 8554 // | 8183 // |
| 8184 // NOTE: Despite the "Proxy-Connection: Close", these are done on the |
| 8185 // same MockTCPClientSocket since the underlying HttpNetworkClientSocket |
| 8186 // does a Disconnect and Connect on the same socket, rather than trying |
| 8187 // to obtain a new one. |
| 8188 // |
| 8555 // NOTE: Originally, the proxy response to the second CONNECT request | 8189 // NOTE: Originally, the proxy response to the second CONNECT request |
| 8556 // simply returned another 407 so the unit test could skip the SSL connection | 8190 // simply returned another 407 so the unit test could skip the SSL connection |
| 8557 // establishment and SPDY framing issues. Alas, the | 8191 // establishment and SPDY framing issues. Alas, the |
| 8558 // retry-http-when-alternate-protocol fails logic kicks in, which was more | 8192 // retry-http-when-alternate-protocol fails logic kicks in, which was more |
| 8559 // complicated to set up expectations for than the SPDY session. | 8193 // complicated to set up expectations for than the SPDY session. |
| 8560 | 8194 |
| 8561 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 8195 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 8562 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 8196 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 8563 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 8197 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
| 8564 | 8198 |
| 8565 MockWrite data_writes_2[] = { | 8199 MockWrite data_writes_2[] = { |
| 8566 // First connection attempt without Proxy-Authorization. | 8200 // First connection attempt without Proxy-Authorization. |
| 8567 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 8201 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 8568 "Host: www.google.com\r\n" | 8202 "Host: www.google.com\r\n" |
| 8569 "Proxy-Connection: keep-alive\r\n" | 8203 "Proxy-Connection: keep-alive\r\n" |
| 8570 "\r\n"), | 8204 "\r\n"), |
| 8571 }; | |
| 8572 | 8205 |
| 8573 MockWrite data_writes_3[] = { | |
| 8574 // Non-alternate protocol job that will run in parallel | |
| 8575 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | |
| 8576 "Host: www.google.com\r\n" | |
| 8577 "Proxy-Connection: keep-alive\r\n" | |
| 8578 "\r\n"), | |
| 8579 }; | |
| 8580 | |
| 8581 MockWrite data_writes_4[] = { | |
| 8582 // Second connection attempt with Proxy-Authorization. | 8206 // Second connection attempt with Proxy-Authorization. |
| 8583 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 8207 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 8584 "Host: www.google.com\r\n" | 8208 "Host: www.google.com\r\n" |
| 8585 "Proxy-Connection: keep-alive\r\n" | 8209 "Proxy-Connection: keep-alive\r\n" |
| 8586 "Proxy-Authorization: auth_token\r\n" | 8210 "Proxy-Authorization: auth_token\r\n" |
| 8587 "\r\n"), | 8211 "\r\n"), |
| 8588 | 8212 |
| 8589 // SPDY request | 8213 // SPDY request |
| 8590 CreateMockWrite(*req), | 8214 CreateMockWrite(*req), |
| 8591 }; | 8215 }; |
| 8592 const char kRejectConnectResponse[] = ("HTTP/1.1 407 Unauthorized\r\n" | 8216 const char kRejectConnectResponse[] = ("HTTP/1.1 407 Unauthorized\r\n" |
| 8593 "Proxy-Authenticate: Mock\r\n" | 8217 "Proxy-Authenticate: Mock\r\n" |
| 8594 "Proxy-Connection: close\r\n" | 8218 "Proxy-Connection: close\r\n" |
| 8595 "Content-Length: 0\r\n" | |
| 8596 "\r\n"); | 8219 "\r\n"); |
| 8597 const char kAcceptConnectResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; | 8220 const char kAcceptConnectResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; |
| 8598 MockRead data_reads_2[] = { | 8221 MockRead data_reads_2[] = { |
| 8599 // First connection attempt fails | 8222 // First connection attempt fails |
| 8600 MockRead(false, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ, 1), | 8223 MockRead(false, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ, 1), |
| 8601 MockRead(true, kRejectConnectResponse, | 8224 MockRead(true, kRejectConnectResponse, |
| 8602 arraysize(kRejectConnectResponse) - 1, 1), | 8225 arraysize(kRejectConnectResponse) - 1, 1), |
| 8603 }; | |
| 8604 | 8226 |
| 8605 // Hang forever so we can ensure the alt job wins | |
| 8606 MockRead data_reads_3[] = { | |
| 8607 MockRead(false, ERR_IO_PENDING), | |
| 8608 }; | |
| 8609 | |
| 8610 MockRead data_reads_4[] = { | |
| 8611 // Second connection attempt passes | 8227 // Second connection attempt passes |
| 8612 MockRead(true, kAcceptConnectResponse, | 8228 MockRead(true, kAcceptConnectResponse, |
| 8613 arraysize(kAcceptConnectResponse) -1, 1), | 8229 arraysize(kAcceptConnectResponse) -1, 4), |
| 8614 | 8230 |
| 8615 // SPDY response | 8231 // SPDY response |
| 8616 CreateMockRead(*resp.get(), 3), | 8232 CreateMockRead(*resp.get(), 6), |
| 8617 CreateMockRead(*data.get(), 3), | 8233 CreateMockRead(*data.get(), 6), |
| 8618 MockRead(true, 0, 0, 4), | 8234 MockRead(true, 0, 0, 6), |
| 8619 }; | 8235 }; |
| 8620 scoped_refptr<OrderedSocketData> data_2( | 8236 scoped_refptr<OrderedSocketData> data_2( |
| 8621 new OrderedSocketData(data_reads_2, arraysize(data_reads_2), | 8237 new OrderedSocketData(data_reads_2, arraysize(data_reads_2), |
| 8622 data_writes_2, arraysize(data_writes_2))); | 8238 data_writes_2, arraysize(data_writes_2))); |
| 8623 scoped_refptr<OrderedSocketData> data_3( | |
| 8624 new OrderedSocketData(data_reads_3, arraysize(data_reads_3), | |
| 8625 data_writes_3, arraysize(data_writes_3))); | |
| 8626 // Hang forever so we can ensure the alt job wins | |
| 8627 MockConnect conn_3(false, ERR_IO_PENDING); | |
| 8628 data_3->set_connect_data(conn_3); | |
| 8629 scoped_refptr<OrderedSocketData> data_4( | |
| 8630 new OrderedSocketData(data_reads_4, arraysize(data_reads_4), | |
| 8631 data_writes_4, arraysize(data_writes_4))); | |
| 8632 | 8239 |
| 8633 SSLSocketDataProvider ssl(true, OK); | 8240 SSLSocketDataProvider ssl(true, OK); |
| 8634 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 8241 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 8635 ssl.next_proto = "spdy/2"; | 8242 ssl.next_proto = "spdy/2"; |
| 8636 ssl.was_npn_negotiated = true; | 8243 ssl.was_npn_negotiated = true; |
| 8637 | 8244 |
| 8638 MockConnect never_finishing_connect(false, ERR_IO_PENDING); | 8245 MockConnect never_finishing_connect(false, ERR_IO_PENDING); |
| 8639 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | 8246 StaticSocketDataProvider hanging_non_alternate_protocol_socket( |
| 8640 NULL, 0, NULL, 0); | 8247 NULL, 0, NULL, 0); |
| 8641 hanging_non_alternate_protocol_socket.set_connect_data( | 8248 hanging_non_alternate_protocol_socket.set_connect_data( |
| 8642 never_finishing_connect); | 8249 never_finishing_connect); |
| 8643 | 8250 |
| 8644 session_deps.socket_factory.AddSocketDataProvider(&data_1); | 8251 session_deps.socket_factory.AddSocketDataProvider(&data_1); |
| 8645 session_deps.socket_factory.AddSocketDataProvider(data_2.get()); | 8252 session_deps.socket_factory.AddSocketDataProvider(data_2.get()); |
| 8646 session_deps.socket_factory.AddSocketDataProvider(data_3.get()); | |
| 8647 session_deps.socket_factory.AddSocketDataProvider(data_4.get()); | |
| 8648 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | |
| 8649 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8253 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 8650 session_deps.socket_factory.AddSocketDataProvider( | 8254 session_deps.socket_factory.AddSocketDataProvider( |
| 8651 &hanging_non_alternate_protocol_socket); | 8255 &hanging_non_alternate_protocol_socket); |
| 8652 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8256 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8653 | 8257 |
| 8654 // First round should work and provide the Alternate-Protocol state. | 8258 // First round should work and provide the Alternate-Protocol state. |
| 8655 TestOldCompletionCallback callback_1; | 8259 TestOldCompletionCallback callback_1; |
| 8656 scoped_ptr<HttpTransaction> trans_1(new HttpNetworkTransaction(session)); | 8260 scoped_ptr<HttpTransaction> trans_1(new HttpNetworkTransaction(session)); |
| 8657 int rv = trans_1->Start(&request, &callback_1, BoundNetLog()); | 8261 int rv = trans_1->Start(&request, &callback_1, BoundNetLog()); |
| 8658 EXPECT_EQ(ERR_IO_PENDING, rv); | 8262 EXPECT_EQ(ERR_IO_PENDING, rv); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8669 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 8273 ASSERT_FALSE(response->auth_challenge.get() == NULL); |
| 8670 | 8274 |
| 8671 // Restart with auth. Tunnel should work and response received. | 8275 // Restart with auth. Tunnel should work and response received. |
| 8672 TestOldCompletionCallback callback_3; | 8276 TestOldCompletionCallback callback_3; |
| 8673 rv = trans_2->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback_3); | 8277 rv = trans_2->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback_3); |
| 8674 EXPECT_EQ(ERR_IO_PENDING, rv); | 8278 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8675 EXPECT_EQ(OK, callback_3.WaitForResult()); | 8279 EXPECT_EQ(OK, callback_3.WaitForResult()); |
| 8676 | 8280 |
| 8677 // After all that work, these two lines (or actually, just the scheme) are | 8281 // After all that work, these two lines (or actually, just the scheme) are |
| 8678 // what this test is all about. Make sure it happens correctly. | 8282 // what this test is all about. Make sure it happens correctly. |
| 8679 const GURL& request_url = auth_handler2->request_url(); | 8283 const GURL& request_url = auth_handler->request_url(); |
| 8680 EXPECT_EQ("https", request_url.scheme()); | 8284 EXPECT_EQ("https", request_url.scheme()); |
| 8681 EXPECT_EQ("www.google.com", request_url.host()); | 8285 EXPECT_EQ("www.google.com", request_url.host()); |
| 8682 | 8286 |
| 8683 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 8287 HttpStreamFactory::set_next_protos(std::vector<std::string>()); |
| 8684 HttpStreamFactory::set_use_alternate_protocols(false); | 8288 HttpStreamFactory::set_use_alternate_protocols(false); |
| 8685 } | 8289 } |
| 8686 | 8290 |
| 8687 // Test that if we cancel the transaction as the connection is completing, that | 8291 // Test that if we cancel the transaction as the connection is completing, that |
| 8688 // everything tears down correctly. | 8292 // everything tears down correctly. |
| 8689 TEST_F(HttpNetworkTransactionTest, SimpleCancel) { | 8293 TEST_F(HttpNetworkTransactionTest, SimpleCancel) { |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9636 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9240 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
| 9637 | 9241 |
| 9638 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9242 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
| 9639 | 9243 |
| 9640 EXPECT_EQ(OK, out.rv); | 9244 EXPECT_EQ(OK, out.rv); |
| 9641 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9245 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
| 9642 EXPECT_EQ("hello world", out.response_data); | 9246 EXPECT_EQ("hello world", out.response_data); |
| 9643 } | 9247 } |
| 9644 | 9248 |
| 9645 } // namespace net | 9249 } // namespace net |
| OLD | NEW |