OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 writes, arraysize(writes))); | 2189 writes, arraysize(writes))); |
2190 scoped_ptr<OrderedSocketData> data2( | 2190 scoped_ptr<OrderedSocketData> data2( |
2191 new OrderedSocketData(reads2, arraysize(reads2), | 2191 new OrderedSocketData(reads2, arraysize(reads2), |
2192 writes2, arraysize(writes2))); | 2192 writes2, arraysize(writes2))); |
2193 | 2193 |
2194 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN | 2194 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN |
2195 HttpStreamFactory::set_force_spdy_over_ssl(false); | 2195 HttpStreamFactory::set_force_spdy_over_ssl(false); |
2196 HttpStreamFactory::set_force_spdy_always(true); | 2196 HttpStreamFactory::set_force_spdy_always(true); |
2197 TestDelegate d; | 2197 TestDelegate d; |
2198 { | 2198 { |
| 2199 SpdyURLRequestContext spdy_url_request_context; |
2199 net::URLRequest r(GURL("http://www.google.com/"), &d); | 2200 net::URLRequest r(GURL("http://www.google.com/"), &d); |
2200 SpdyURLRequestContext* spdy_url_request_context = | 2201 r.set_context(&spdy_url_request_context); |
2201 new SpdyURLRequestContext(); | 2202 spdy_url_request_context.socket_factory(). |
2202 r.set_context(spdy_url_request_context); | |
2203 spdy_url_request_context->socket_factory(). | |
2204 AddSocketDataProvider(data.get()); | 2203 AddSocketDataProvider(data.get()); |
2205 spdy_url_request_context->socket_factory(). | 2204 spdy_url_request_context.socket_factory(). |
2206 AddSocketDataProvider(data2.get()); | 2205 AddSocketDataProvider(data2.get()); |
2207 | 2206 |
2208 d.set_quit_on_redirect(true); | 2207 d.set_quit_on_redirect(true); |
2209 r.Start(); | 2208 r.Start(); |
2210 MessageLoop::current()->Run(); | 2209 MessageLoop::current()->Run(); |
2211 | 2210 |
2212 EXPECT_EQ(1, d.received_redirect_count()); | 2211 EXPECT_EQ(1, d.received_redirect_count()); |
2213 | 2212 |
2214 r.FollowDeferredRedirect(); | 2213 r.FollowDeferredRedirect(); |
2215 MessageLoop::current()->Run(); | 2214 MessageLoop::current()->Run(); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 writes, arraysize(writes))); | 2444 writes, arraysize(writes))); |
2446 scoped_ptr<OrderedSocketData> data2( | 2445 scoped_ptr<OrderedSocketData> data2( |
2447 new OrderedSocketData(reads2, arraysize(reads2), | 2446 new OrderedSocketData(reads2, arraysize(reads2), |
2448 writes2, arraysize(writes2))); | 2447 writes2, arraysize(writes2))); |
2449 | 2448 |
2450 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN | 2449 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN |
2451 HttpStreamFactory::set_force_spdy_over_ssl(false); | 2450 HttpStreamFactory::set_force_spdy_over_ssl(false); |
2452 HttpStreamFactory::set_force_spdy_always(true); | 2451 HttpStreamFactory::set_force_spdy_always(true); |
2453 TestDelegate d; | 2452 TestDelegate d; |
2454 TestDelegate d2; | 2453 TestDelegate d2; |
2455 scoped_refptr<SpdyURLRequestContext> spdy_url_request_context( | 2454 SpdyURLRequestContext spdy_url_request_context; |
2456 new SpdyURLRequestContext()); | |
2457 { | 2455 { |
2458 net::URLRequest r(GURL("http://www.google.com/"), &d); | 2456 net::URLRequest r(GURL("http://www.google.com/"), &d); |
2459 r.set_context(spdy_url_request_context); | 2457 r.set_context(&spdy_url_request_context); |
2460 spdy_url_request_context->socket_factory(). | 2458 spdy_url_request_context.socket_factory(). |
2461 AddSocketDataProvider(data.get()); | 2459 AddSocketDataProvider(data.get()); |
2462 | 2460 |
2463 r.Start(); | 2461 r.Start(); |
2464 MessageLoop::current()->Run(); | 2462 MessageLoop::current()->Run(); |
2465 | 2463 |
2466 EXPECT_EQ(0, d.received_redirect_count()); | 2464 EXPECT_EQ(0, d.received_redirect_count()); |
2467 std::string contents("hello!"); | 2465 std::string contents("hello!"); |
2468 EXPECT_EQ(contents, d.data_received()); | 2466 EXPECT_EQ(contents, d.data_received()); |
2469 | 2467 |
2470 net::URLRequest r2(GURL("http://www.google.com/foo.dat"), &d2); | 2468 net::URLRequest r2(GURL("http://www.google.com/foo.dat"), &d2); |
2471 r2.set_context(spdy_url_request_context); | 2469 r2.set_context(&spdy_url_request_context); |
2472 spdy_url_request_context->socket_factory(). | 2470 spdy_url_request_context.socket_factory(). |
2473 AddSocketDataProvider(data2.get()); | 2471 AddSocketDataProvider(data2.get()); |
2474 | 2472 |
2475 d2.set_quit_on_redirect(true); | 2473 d2.set_quit_on_redirect(true); |
2476 r2.Start(); | 2474 r2.Start(); |
2477 MessageLoop::current()->Run(); | 2475 MessageLoop::current()->Run(); |
2478 EXPECT_EQ(1, d2.received_redirect_count()); | 2476 EXPECT_EQ(1, d2.received_redirect_count()); |
2479 | 2477 |
2480 r2.FollowDeferredRedirect(); | 2478 r2.FollowDeferredRedirect(); |
2481 MessageLoop::current()->Run(); | 2479 MessageLoop::current()->Run(); |
2482 EXPECT_EQ(1, d2.response_started_count()); | 2480 EXPECT_EQ(1, d2.response_started_count()); |
(...skipping 3074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5557 << " Write index: " | 5555 << " Write index: " |
5558 << data->write_index(); | 5556 << data->write_index(); |
5559 | 5557 |
5560 // Verify the SYN_REPLY. | 5558 // Verify the SYN_REPLY. |
5561 HttpResponseInfo response = *trans->GetResponseInfo(); | 5559 HttpResponseInfo response = *trans->GetResponseInfo(); |
5562 EXPECT_TRUE(response.headers != NULL); | 5560 EXPECT_TRUE(response.headers != NULL); |
5563 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5561 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5564 } | 5562 } |
5565 | 5563 |
5566 } // namespace net | 5564 } // namespace net |
OLD | NEW |