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 2749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2760 writes, arraysize(writes))); | 2760 writes, arraysize(writes))); |
2761 scoped_ptr<OrderedSocketData> data2( | 2761 scoped_ptr<OrderedSocketData> data2( |
2762 new OrderedSocketData(reads2, arraysize(reads2), | 2762 new OrderedSocketData(reads2, arraysize(reads2), |
2763 writes2, arraysize(writes2))); | 2763 writes2, arraysize(writes2))); |
2764 | 2764 |
2765 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN | 2765 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN |
2766 HttpStreamFactory::set_force_spdy_over_ssl(false); | 2766 HttpStreamFactory::set_force_spdy_over_ssl(false); |
2767 HttpStreamFactory::set_force_spdy_always(true); | 2767 HttpStreamFactory::set_force_spdy_always(true); |
2768 TestDelegate d; | 2768 TestDelegate d; |
2769 { | 2769 { |
| 2770 SpdyURLRequestContext spdy_url_request_context; |
2770 net::URLRequest r(GURL("http://www.google.com/"), &d); | 2771 net::URLRequest r(GURL("http://www.google.com/"), &d); |
2771 SpdyURLRequestContext* spdy_url_request_context = | 2772 r.set_context(&spdy_url_request_context); |
2772 new SpdyURLRequestContext(); | 2773 spdy_url_request_context.socket_factory(). |
2773 r.set_context(spdy_url_request_context); | |
2774 spdy_url_request_context->socket_factory(). | |
2775 AddSocketDataProvider(data.get()); | 2774 AddSocketDataProvider(data.get()); |
2776 spdy_url_request_context->socket_factory(). | 2775 spdy_url_request_context.socket_factory(). |
2777 AddSocketDataProvider(data2.get()); | 2776 AddSocketDataProvider(data2.get()); |
2778 | 2777 |
2779 d.set_quit_on_redirect(true); | 2778 d.set_quit_on_redirect(true); |
2780 r.Start(); | 2779 r.Start(); |
2781 MessageLoop::current()->Run(); | 2780 MessageLoop::current()->Run(); |
2782 EXPECT_EQ(1, d.received_redirect_count()); | 2781 EXPECT_EQ(1, d.received_redirect_count()); |
2783 | 2782 |
2784 r.FollowDeferredRedirect(); | 2783 r.FollowDeferredRedirect(); |
2785 MessageLoop::current()->Run(); | 2784 MessageLoop::current()->Run(); |
2786 EXPECT_EQ(1, d.response_started_count()); | 2785 EXPECT_EQ(1, d.response_started_count()); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 writes, arraysize(writes))); | 3017 writes, arraysize(writes))); |
3019 scoped_ptr<OrderedSocketData> data2( | 3018 scoped_ptr<OrderedSocketData> data2( |
3020 new OrderedSocketData(reads2, arraysize(reads2), | 3019 new OrderedSocketData(reads2, arraysize(reads2), |
3021 writes2, arraysize(writes2))); | 3020 writes2, arraysize(writes2))); |
3022 | 3021 |
3023 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN | 3022 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN |
3024 HttpStreamFactory::set_force_spdy_over_ssl(false); | 3023 HttpStreamFactory::set_force_spdy_over_ssl(false); |
3025 HttpStreamFactory::set_force_spdy_always(true); | 3024 HttpStreamFactory::set_force_spdy_always(true); |
3026 TestDelegate d; | 3025 TestDelegate d; |
3027 TestDelegate d2; | 3026 TestDelegate d2; |
3028 scoped_refptr<SpdyURLRequestContext> spdy_url_request_context( | 3027 SpdyURLRequestContext spdy_url_request_context; |
3029 new SpdyURLRequestContext()); | |
3030 { | 3028 { |
3031 net::URLRequest r(GURL("http://www.google.com/"), &d); | 3029 net::URLRequest r(GURL("http://www.google.com/"), &d); |
3032 r.set_context(spdy_url_request_context); | 3030 r.set_context(&spdy_url_request_context); |
3033 spdy_url_request_context->socket_factory(). | 3031 spdy_url_request_context.socket_factory(). |
3034 AddSocketDataProvider(data.get()); | 3032 AddSocketDataProvider(data.get()); |
3035 | 3033 |
3036 r.Start(); | 3034 r.Start(); |
3037 MessageLoop::current()->Run(); | 3035 MessageLoop::current()->Run(); |
3038 | 3036 |
3039 EXPECT_EQ(0, d.received_redirect_count()); | 3037 EXPECT_EQ(0, d.received_redirect_count()); |
3040 std::string contents("hello!"); | 3038 std::string contents("hello!"); |
3041 EXPECT_EQ(contents, d.data_received()); | 3039 EXPECT_EQ(contents, d.data_received()); |
3042 | 3040 |
3043 net::URLRequest r2(GURL("http://www.google.com/foo.dat"), &d2); | 3041 net::URLRequest r2(GURL("http://www.google.com/foo.dat"), &d2); |
3044 r2.set_context(spdy_url_request_context); | 3042 r2.set_context(&spdy_url_request_context); |
3045 spdy_url_request_context->socket_factory(). | 3043 spdy_url_request_context.socket_factory(). |
3046 AddSocketDataProvider(data2.get()); | 3044 AddSocketDataProvider(data2.get()); |
3047 | 3045 |
3048 d2.set_quit_on_redirect(true); | 3046 d2.set_quit_on_redirect(true); |
3049 r2.Start(); | 3047 r2.Start(); |
3050 MessageLoop::current()->Run(); | 3048 MessageLoop::current()->Run(); |
3051 EXPECT_EQ(1, d2.received_redirect_count()); | 3049 EXPECT_EQ(1, d2.received_redirect_count()); |
3052 | 3050 |
3053 r2.FollowDeferredRedirect(); | 3051 r2.FollowDeferredRedirect(); |
3054 MessageLoop::current()->Run(); | 3052 MessageLoop::current()->Run(); |
3055 EXPECT_EQ(1, d2.response_started_count()); | 3053 EXPECT_EQ(1, d2.response_started_count()); |
(...skipping 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6140 << " Write index: " | 6138 << " Write index: " |
6141 << data->write_index(); | 6139 << data->write_index(); |
6142 | 6140 |
6143 // Verify the SYN_REPLY. | 6141 // Verify the SYN_REPLY. |
6144 HttpResponseInfo response = *trans->GetResponseInfo(); | 6142 HttpResponseInfo response = *trans->GetResponseInfo(); |
6145 EXPECT_TRUE(response.headers != NULL); | 6143 EXPECT_TRUE(response.headers != NULL); |
6146 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 6144 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
6147 } | 6145 } |
6148 | 6146 |
6149 } // namespace net | 6147 } // namespace net |
OLD | NEW |