OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "net/base/mock_host_resolver.h" | 10 #include "net/base/mock_host_resolver.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 MockWrite data_writes2[] = { | 301 MockWrite data_writes2[] = { |
302 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" | 302 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" |
303 "Host: example.com\r\n" | 303 "Host: example.com\r\n" |
304 "Proxy-Connection: keep-alive\r\n" | 304 "Proxy-Connection: keep-alive\r\n" |
305 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 305 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
306 }; | 306 }; |
307 MockRead data_reads2[] = { | 307 MockRead data_reads2[] = { |
308 MockRead("HTTP/1.1 200 Connection Established\r\n"), | 308 MockRead("HTTP/1.1 200 Connection Established\r\n"), |
309 MockRead("Proxy-agent: Apache/2.2.8\r\n"), | 309 MockRead("Proxy-agent: Apache/2.2.8\r\n"), |
310 MockRead("\r\n"), | 310 MockRead("\r\n"), |
| 311 // SocketStream::DoClose is run asynchronously. Socket can be read after |
| 312 // "\r\n". We have to give ERR_IO_PENDING to SocketStream then to indicate |
| 313 // server doesn't close the connection. |
| 314 MockRead(true, ERR_IO_PENDING) |
311 }; | 315 }; |
312 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 316 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
313 data_writes2, arraysize(data_writes2)); | 317 data_writes2, arraysize(data_writes2)); |
314 mock_socket_factory.AddSocketDataProvider(&data2); | 318 mock_socket_factory.AddSocketDataProvider(&data2); |
315 | 319 |
316 TestCompletionCallback callback; | 320 TestCompletionCallback callback; |
317 | 321 |
318 scoped_ptr<SocketStreamEventRecorder> delegate( | 322 scoped_ptr<SocketStreamEventRecorder> delegate( |
319 new SocketStreamEventRecorder(&callback)); | 323 new SocketStreamEventRecorder(&callback)); |
320 delegate->SetOnConnected(NewCallback(delegate.get(), | 324 delegate->SetOnConnected(NewCallback(delegate.get(), |
(...skipping 18 matching lines...) Expand all Loading... |
339 EXPECT_EQ(3U, events.size()); | 343 EXPECT_EQ(3U, events.size()); |
340 | 344 |
341 EXPECT_EQ(SocketStreamEvent::EVENT_AUTH_REQUIRED, events[0].event_type); | 345 EXPECT_EQ(SocketStreamEvent::EVENT_AUTH_REQUIRED, events[0].event_type); |
342 EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type); | 346 EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type); |
343 EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[2].event_type); | 347 EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[2].event_type); |
344 | 348 |
345 // TODO(eroman): Add back NetLogTest here... | 349 // TODO(eroman): Add back NetLogTest here... |
346 } | 350 } |
347 | 351 |
348 } // namespace net | 352 } // namespace net |
OLD | NEW |