OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "net/base/load_log.h" | 8 #include "net/base/load_log.h" |
9 #include "net/base/load_log_unittest.h" | 9 #include "net/base/load_log_unittest.h" |
10 #include "net/base/mock_host_resolver.h" | 10 #include "net/base/mock_host_resolver.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 MockWrite data_writes1[] = { | 153 MockWrite data_writes1[] = { |
154 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" | 154 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" |
155 "Host: example.com\r\n" | 155 "Host: example.com\r\n" |
156 "Proxy-Connection: keep-alive\r\n\r\n"), | 156 "Proxy-Connection: keep-alive\r\n\r\n"), |
157 }; | 157 }; |
158 MockRead data_reads1[] = { | 158 MockRead data_reads1[] = { |
159 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 159 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
160 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 160 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
161 MockRead("\r\n"), | 161 MockRead("\r\n"), |
162 }; | 162 }; |
163 StaticSocketDataProvider data1(data_reads1, data_writes1); | 163 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 164 data_writes1, arraysize(data_writes1)); |
164 mock_socket_factory.AddSocketDataProvider(&data1); | 165 mock_socket_factory.AddSocketDataProvider(&data1); |
165 | 166 |
166 MockWrite data_writes2[] = { | 167 MockWrite data_writes2[] = { |
167 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" | 168 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" |
168 "Host: example.com\r\n" | 169 "Host: example.com\r\n" |
169 "Proxy-Connection: keep-alive\r\n" | 170 "Proxy-Connection: keep-alive\r\n" |
170 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 171 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
171 }; | 172 }; |
172 MockRead data_reads2[] = { | 173 MockRead data_reads2[] = { |
173 MockRead("HTTP/1.1 200 Connection Established\r\n"), | 174 MockRead("HTTP/1.1 200 Connection Established\r\n"), |
174 MockRead("Proxy-agent: Apache/2.2.8\r\n"), | 175 MockRead("Proxy-agent: Apache/2.2.8\r\n"), |
175 MockRead("\r\n"), | 176 MockRead("\r\n"), |
176 }; | 177 }; |
177 StaticSocketDataProvider data2(data_reads2, data_writes2); | 178 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 179 data_writes2, arraysize(data_writes2)); |
178 mock_socket_factory.AddSocketDataProvider(&data2); | 180 mock_socket_factory.AddSocketDataProvider(&data2); |
179 | 181 |
180 TestCompletionCallback callback; | 182 TestCompletionCallback callback; |
181 | 183 |
182 scoped_ptr<SocketStreamEventRecorder> delegate( | 184 scoped_ptr<SocketStreamEventRecorder> delegate( |
183 new SocketStreamEventRecorder(&callback)); | 185 new SocketStreamEventRecorder(&callback)); |
184 delegate->SetOnConnected(NewCallback(delegate.get(), | 186 delegate->SetOnConnected(NewCallback(delegate.get(), |
185 &SocketStreamEventRecorder::DoClose)); | 187 &SocketStreamEventRecorder::DoClose)); |
186 const std::wstring kUsername = L"foo"; | 188 const std::wstring kUsername = L"foo"; |
187 const std::wstring kPassword = L"bar"; | 189 const std::wstring kPassword = L"bar"; |
(...skipping 22 matching lines...) Expand all Loading... |
210 | 212 |
211 // The first and last entries of the LoadLog should be for | 213 // The first and last entries of the LoadLog should be for |
212 // SOCKET_STREAM_CONNECT. | 214 // SOCKET_STREAM_CONNECT. |
213 EXPECT_TRUE(LogContainsBeginEvent( | 215 EXPECT_TRUE(LogContainsBeginEvent( |
214 *socket_stream->load_log(), 0, LoadLog::TYPE_SOCKET_STREAM_CONNECT)); | 216 *socket_stream->load_log(), 0, LoadLog::TYPE_SOCKET_STREAM_CONNECT)); |
215 EXPECT_TRUE(LogContainsEndEvent( | 217 EXPECT_TRUE(LogContainsEndEvent( |
216 *socket_stream->load_log(), -1, LoadLog::TYPE_SOCKET_STREAM_CONNECT)); | 218 *socket_stream->load_log(), -1, LoadLog::TYPE_SOCKET_STREAM_CONNECT)); |
217 } | 219 } |
218 | 220 |
219 } // namespace net | 221 } // namespace net |
OLD | NEW |