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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 // the session receives an empty frame after this one, it shuts down the | 2278 // the session receives an empty frame after this one, it shuts down the |
2279 // session, and calls the read callback with the incomplete data. | 2279 // session, and calls the read callback with the incomplete data. |
2280 const uint8 kGetBodyFrame2[] = { | 2280 const uint8 kGetBodyFrame2[] = { |
2281 0x00, 0x00, 0x00, 0x01, | 2281 0x00, 0x00, 0x00, 0x01, |
2282 0x01, 0x00, 0x00, 0x07, | 2282 0x01, 0x00, 0x00, 0x07, |
2283 'h', 'e', 'l', 'l', 'o', '!', | 2283 'h', 'e', 'l', 'l', 'o', '!', |
2284 }; | 2284 }; |
2285 | 2285 |
2286 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2286 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
2287 MockRead reads[] = { | 2287 MockRead reads[] = { |
2288 CreateMockRead(*resp, 1), | 2288 CreateMockRead(*resp, 2), |
2289 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause | 2289 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause |
2290 MockRead(ASYNC, reinterpret_cast<const char*>(kGetBodyFrame2), | 2290 MockRead(ASYNC, reinterpret_cast<const char*>(kGetBodyFrame2), |
2291 arraysize(kGetBodyFrame2), 3), | 2291 arraysize(kGetBodyFrame2), 4), |
2292 MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause | 2292 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause |
2293 MockRead(ASYNC, 0, 0, 5), // EOF | 2293 MockRead(ASYNC, 0, 0, 6), // EOF |
2294 }; | 2294 }; |
2295 MockRead reads2[] = { | 2295 MockRead reads2[] = { |
2296 CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 0, 2), // EOF | 2296 CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 0, 2), // EOF |
2297 }; | 2297 }; |
2298 | 2298 |
2299 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2299 OrderedSocketData data(reads, arraysize(reads), |
| 2300 writes, arraysize(writes)); |
2300 SequencedSocketData data2(reads2, arraysize(reads2), writes2, | 2301 SequencedSocketData data2(reads2, arraysize(reads2), writes2, |
2301 arraysize(writes2)); | 2302 arraysize(writes2)); |
2302 | 2303 |
2303 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2304 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2304 BoundNetLog(), GetParam(), NULL); | 2305 BoundNetLog(), GetParam(), NULL); |
2305 helper.RunPreTestSetup(); | 2306 helper.RunPreTestSetup(); |
2306 helper.AddData(&data); | 2307 helper.AddData(&data); |
2307 helper.AddData(&data2); | 2308 helper.AddData(&data2); |
2308 HttpNetworkTransaction* trans = helper.trans(); | 2309 HttpNetworkTransaction* trans = helper.trans(); |
2309 | 2310 |
2310 // Start the transaction with basic parameters. | 2311 // Start the transaction with basic parameters. |
2311 TestCompletionCallback callback; | 2312 TestCompletionCallback callback; |
2312 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2313 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2313 EXPECT_EQ(ERR_IO_PENDING, rv); | 2314 EXPECT_EQ(ERR_IO_PENDING, rv); |
2314 rv = callback.WaitForResult(); | 2315 rv = callback.WaitForResult(); |
2315 | 2316 |
2316 const int kSize = 3000; | 2317 const int kSize = 3000; |
2317 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); | 2318 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); |
2318 rv = trans->Read( | 2319 rv = trans->Read( |
2319 buf.get(), kSize, | 2320 buf.get(), kSize, |
2320 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, | 2321 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, |
2321 helper.session(), GURL(GetDefaultUrl()))); | 2322 helper.session(), GURL(GetDefaultUrl()))); |
2322 ASSERT_EQ(ERR_IO_PENDING, rv); | |
2323 // This forces an err_IO_pending, which sets the callback. | 2323 // This forces an err_IO_pending, which sets the callback. |
2324 data.CompleteRead(); | 2324 data.CompleteRead(); |
2325 // This finishes the read. | 2325 // This finishes the read. |
2326 data.CompleteRead(); | 2326 data.CompleteRead(); |
2327 helper.VerifyDataConsumed(); | 2327 helper.VerifyDataConsumed(); |
2328 } | 2328 } |
2329 | 2329 |
2330 // Verify that the client can correctly deal with the user callback deleting the | 2330 // Verify that the client can correctly deal with the user callback deleting the |
2331 // transaction. Failures will usually be valgrind errors. See | 2331 // transaction. Failures will usually be valgrind errors. See |
2332 // http://crbug.com/46925 | 2332 // http://crbug.com/46925 |
2333 TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) { | 2333 TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) { |
2334 scoped_ptr<SpdyFrame> req( | 2334 scoped_ptr<SpdyFrame> req( |
2335 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2335 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
2336 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 2336 MockWrite writes[] = { CreateMockWrite(*req) }; |
2337 | 2337 |
2338 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2338 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
2339 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2339 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
2340 MockRead reads[] = { | 2340 MockRead reads[] = { |
2341 CreateMockRead(*resp.get(), 1), | 2341 CreateMockRead(*resp.get(), 2), |
2342 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause | 2342 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause |
2343 CreateMockRead(*body.get(), 3), | 2343 CreateMockRead(*body.get(), 4), |
2344 MockRead(ASYNC, 0, 0, 4), // EOF | 2344 MockRead(ASYNC, 0, 0, 5), // EOF |
2345 }; | 2345 }; |
2346 | 2346 |
2347 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2347 OrderedSocketData data(reads, arraysize(reads), |
| 2348 writes, arraysize(writes)); |
2348 | 2349 |
2349 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2350 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2350 BoundNetLog(), GetParam(), NULL); | 2351 BoundNetLog(), GetParam(), NULL); |
2351 helper.RunPreTestSetup(); | 2352 helper.RunPreTestSetup(); |
2352 helper.AddData(&data); | 2353 helper.AddData(&data); |
2353 HttpNetworkTransaction* trans = helper.trans(); | 2354 HttpNetworkTransaction* trans = helper.trans(); |
2354 | 2355 |
2355 // Start the transaction with basic parameters. | 2356 // Start the transaction with basic parameters. |
2356 TestCompletionCallback callback; | 2357 TestCompletionCallback callback; |
2357 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2358 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3666 }; | 3667 }; |
3667 char combined_data_frames[100]; | 3668 char combined_data_frames[100]; |
3668 int combined_data_frames_len = | 3669 int combined_data_frames_len = |
3669 CombineFrames(data_frames, arraysize(data_frames), | 3670 CombineFrames(data_frames, arraysize(data_frames), |
3670 combined_data_frames, arraysize(combined_data_frames)); | 3671 combined_data_frames, arraysize(combined_data_frames)); |
3671 scoped_ptr<SpdyFrame> last_frame( | 3672 scoped_ptr<SpdyFrame> last_frame( |
3672 framer.CreateDataFrame(1, "d", 1, DATA_FLAG_FIN)); | 3673 framer.CreateDataFrame(1, "d", 1, DATA_FLAG_FIN)); |
3673 | 3674 |
3674 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3675 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3675 MockRead reads[] = { | 3676 MockRead reads[] = { |
3676 CreateMockRead(*resp, 1), | 3677 CreateMockRead(*resp), |
3677 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause | 3678 MockRead(ASYNC, ERR_IO_PENDING), // Force a pause |
3678 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), | 3679 MockRead(ASYNC, combined_data_frames, combined_data_frames_len), |
3679 MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause | 3680 MockRead(ASYNC, ERR_IO_PENDING), // Force a pause |
3680 CreateMockRead(*last_frame, 5), | 3681 CreateMockRead(*last_frame), |
3681 MockRead(ASYNC, 0, 6) // EOF | 3682 MockRead(ASYNC, 0, 0) // EOF |
3682 }; | 3683 }; |
3683 | 3684 |
3684 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3685 DelayedSocketData data(1, reads, arraysize(reads), |
| 3686 writes, arraysize(writes)); |
3685 | 3687 |
3686 TestCompletionCallback callback; | 3688 TestCompletionCallback callback; |
3687 | 3689 |
3688 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3690 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3689 BoundNetLog(), GetParam(), NULL); | 3691 BoundNetLog(), GetParam(), NULL); |
3690 helper.RunPreTestSetup(); | 3692 helper.RunPreTestSetup(); |
3691 helper.AddData(&data); | 3693 helper.AddData(&data); |
3692 HttpNetworkTransaction* trans = helper.trans(); | 3694 HttpNetworkTransaction* trans = helper.trans(); |
3693 int rv = trans->Start( | 3695 int rv = trans->Start( |
3694 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3696 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3739 } | 3741 } |
3740 | 3742 |
3741 // Verify that basic buffering works; when multiple data frames arrive | 3743 // Verify that basic buffering works; when multiple data frames arrive |
3742 // at the same time, ensure that we don't notify a read completion for | 3744 // at the same time, ensure that we don't notify a read completion for |
3743 // each data frame individually. | 3745 // each data frame individually. |
3744 TEST_P(SpdyNetworkTransactionTest, Buffering) { | 3746 TEST_P(SpdyNetworkTransactionTest, Buffering) { |
3745 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 3747 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
3746 | 3748 |
3747 scoped_ptr<SpdyFrame> req( | 3749 scoped_ptr<SpdyFrame> req( |
3748 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3750 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3749 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 3751 MockWrite writes[] = { CreateMockWrite(*req) }; |
3750 | 3752 |
3751 // 4 data frames in a single read. | 3753 // 4 data frames in a single read. |
3752 scoped_ptr<SpdyFrame> data_frame( | 3754 scoped_ptr<SpdyFrame> data_frame( |
3753 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 3755 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
3754 scoped_ptr<SpdyFrame> data_frame_fin( | 3756 scoped_ptr<SpdyFrame> data_frame_fin( |
3755 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); | 3757 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); |
3756 const SpdyFrame* data_frames[4] = { | 3758 const SpdyFrame* data_frames[4] = { |
3757 data_frame.get(), | 3759 data_frame.get(), |
3758 data_frame.get(), | 3760 data_frame.get(), |
3759 data_frame.get(), | 3761 data_frame.get(), |
3760 data_frame_fin.get() | 3762 data_frame_fin.get() |
3761 }; | 3763 }; |
3762 char combined_data_frames[100]; | 3764 char combined_data_frames[100]; |
3763 int combined_data_frames_len = | 3765 int combined_data_frames_len = |
3764 CombineFrames(data_frames, arraysize(data_frames), | 3766 CombineFrames(data_frames, arraysize(data_frames), |
3765 combined_data_frames, arraysize(combined_data_frames)); | 3767 combined_data_frames, arraysize(combined_data_frames)); |
3766 | 3768 |
3767 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3769 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3768 MockRead reads[] = { | 3770 MockRead reads[] = { |
3769 CreateMockRead(*resp, 1), | 3771 CreateMockRead(*resp), |
3770 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause | 3772 MockRead(ASYNC, ERR_IO_PENDING), // Force a pause |
3771 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), | 3773 MockRead(ASYNC, combined_data_frames, combined_data_frames_len), |
3772 MockRead(ASYNC, 0, 4) // EOF | 3774 MockRead(ASYNC, 0, 0) // EOF |
3773 }; | 3775 }; |
3774 | 3776 |
3775 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3777 DelayedSocketData data(1, reads, arraysize(reads), |
| 3778 writes, arraysize(writes)); |
3776 | 3779 |
3777 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3780 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3778 BoundNetLog(), GetParam(), NULL); | 3781 BoundNetLog(), GetParam(), NULL); |
3779 helper.RunPreTestSetup(); | 3782 helper.RunPreTestSetup(); |
3780 helper.AddData(&data); | 3783 helper.AddData(&data); |
3781 HttpNetworkTransaction* trans = helper.trans(); | 3784 HttpNetworkTransaction* trans = helper.trans(); |
3782 | 3785 |
3783 TestCompletionCallback callback; | 3786 TestCompletionCallback callback; |
3784 int rv = trans->Start( | 3787 int rv = trans->Start( |
3785 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3788 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3917 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 3920 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
3918 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 3921 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
3919 } | 3922 } |
3920 | 3923 |
3921 // Verify the case where we buffer data and close the connection. | 3924 // Verify the case where we buffer data and close the connection. |
3922 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { | 3925 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { |
3923 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 3926 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
3924 | 3927 |
3925 scoped_ptr<SpdyFrame> req( | 3928 scoped_ptr<SpdyFrame> req( |
3926 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3929 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3927 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 3930 MockWrite writes[] = { CreateMockWrite(*req) }; |
3928 | 3931 |
3929 // All data frames in a single read. | 3932 // All data frames in a single read. |
3930 // NOTE: We don't FIN the stream. | 3933 // NOTE: We don't FIN the stream. |
3931 scoped_ptr<SpdyFrame> data_frame( | 3934 scoped_ptr<SpdyFrame> data_frame( |
3932 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 3935 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
3933 const SpdyFrame* data_frames[4] = { | 3936 const SpdyFrame* data_frames[4] = { |
3934 data_frame.get(), | 3937 data_frame.get(), |
3935 data_frame.get(), | 3938 data_frame.get(), |
3936 data_frame.get(), | 3939 data_frame.get(), |
3937 data_frame.get() | 3940 data_frame.get() |
3938 }; | 3941 }; |
3939 char combined_data_frames[100]; | 3942 char combined_data_frames[100]; |
3940 int combined_data_frames_len = | 3943 int combined_data_frames_len = |
3941 CombineFrames(data_frames, arraysize(data_frames), | 3944 CombineFrames(data_frames, arraysize(data_frames), |
3942 combined_data_frames, arraysize(combined_data_frames)); | 3945 combined_data_frames, arraysize(combined_data_frames)); |
3943 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3946 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3944 MockRead reads[] = { | 3947 MockRead reads[] = { |
3945 CreateMockRead(*resp, 1), | 3948 CreateMockRead(*resp), |
3946 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a wait | 3949 MockRead(ASYNC, ERR_IO_PENDING), // Force a wait |
3947 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), | 3950 MockRead(ASYNC, combined_data_frames, combined_data_frames_len), |
3948 MockRead(ASYNC, 0, 4) // EOF | 3951 MockRead(ASYNC, 0, 0) // EOF |
3949 }; | 3952 }; |
3950 | 3953 |
3951 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3954 DelayedSocketData data(1, reads, arraysize(reads), |
| 3955 writes, arraysize(writes)); |
3952 | 3956 |
3953 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3957 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3954 BoundNetLog(), GetParam(), NULL); | 3958 BoundNetLog(), GetParam(), NULL); |
3955 helper.RunPreTestSetup(); | 3959 helper.RunPreTestSetup(); |
3956 helper.AddData(&data); | 3960 helper.AddData(&data); |
3957 HttpNetworkTransaction* trans = helper.trans(); | 3961 HttpNetworkTransaction* trans = helper.trans(); |
3958 | 3962 |
3959 TestCompletionCallback callback; | 3963 TestCompletionCallback callback; |
3960 | 3964 |
3961 int rv = trans->Start( | 3965 int rv = trans->Start( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4009 } | 4013 } |
4010 | 4014 |
4011 // Verify the case where we buffer data and cancel the transaction. | 4015 // Verify the case where we buffer data and cancel the transaction. |
4012 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { | 4016 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { |
4013 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4017 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
4014 | 4018 |
4015 scoped_ptr<SpdyFrame> req( | 4019 scoped_ptr<SpdyFrame> req( |
4016 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4020 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
4017 scoped_ptr<SpdyFrame> rst( | 4021 scoped_ptr<SpdyFrame> rst( |
4018 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 4022 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
4019 MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4)}; | 4023 MockWrite writes[] = {CreateMockWrite(*req), CreateMockWrite(*rst)}; |
4020 | 4024 |
4021 // NOTE: We don't FIN the stream. | 4025 // NOTE: We don't FIN the stream. |
4022 scoped_ptr<SpdyFrame> data_frame( | 4026 scoped_ptr<SpdyFrame> data_frame( |
4023 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 4027 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
4024 | 4028 |
4025 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4029 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
4026 MockRead reads[] = { | 4030 MockRead reads[] = { |
4027 CreateMockRead(*resp, 1), | 4031 CreateMockRead(*resp), |
4028 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a wait | 4032 MockRead(ASYNC, ERR_IO_PENDING), // Force a wait |
4029 CreateMockRead(*data_frame, 3), | 4033 CreateMockRead(*data_frame), |
4030 MockRead(ASYNC, 0, 5) // EOF | 4034 MockRead(ASYNC, 0, 0) // EOF |
4031 }; | 4035 }; |
4032 | 4036 |
4033 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4037 DelayedSocketData data(1, reads, arraysize(reads), |
| 4038 writes, arraysize(writes)); |
4034 | 4039 |
4035 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4040 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
4036 BoundNetLog(), GetParam(), NULL); | 4041 BoundNetLog(), GetParam(), NULL); |
4037 helper.RunPreTestSetup(); | 4042 helper.RunPreTestSetup(); |
4038 helper.AddData(&data); | 4043 helper.AddData(&data); |
4039 HttpNetworkTransaction* trans = helper.trans(); | 4044 HttpNetworkTransaction* trans = helper.trans(); |
4040 TestCompletionCallback callback; | 4045 TestCompletionCallback callback; |
4041 | 4046 |
4042 int rv = trans->Start( | 4047 int rv = trans->Start( |
4043 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4048 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4252 const SettingsMap& settings = | 4257 const SettingsMap& settings = |
4253 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4258 spdy_session_pool->http_server_properties()->GetSpdySettings( |
4254 host_port_pair); | 4259 host_port_pair); |
4255 scoped_ptr<SpdyFrame> settings_frame( | 4260 scoped_ptr<SpdyFrame> settings_frame( |
4256 spdy_util_.ConstructSpdySettings(settings)); | 4261 spdy_util_.ConstructSpdySettings(settings)); |
4257 | 4262 |
4258 // Construct the request. | 4263 // Construct the request. |
4259 scoped_ptr<SpdyFrame> req( | 4264 scoped_ptr<SpdyFrame> req( |
4260 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4265 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
4261 | 4266 |
4262 MockWrite writes[] = { | 4267 std::vector<MockWrite> writes; |
4263 CreateMockWrite(*initial_settings_frame, 0), | 4268 if ((GetParam().protocol >= kProtoSPDY4MinimumVersion) && |
4264 CreateMockWrite(*settings_frame, 1), | 4269 (GetParam().protocol <= kProtoSPDY4MaximumVersion)) { |
4265 CreateMockWrite(*req, 2), | 4270 writes.push_back( |
4266 }; | 4271 MockWrite(ASYNC, |
| 4272 kHttp2ConnectionHeaderPrefix, |
| 4273 kHttp2ConnectionHeaderPrefixSize)); |
| 4274 } |
| 4275 writes.push_back(CreateMockWrite(*initial_settings_frame)); |
| 4276 writes.push_back(CreateMockWrite(*settings_frame)); |
| 4277 writes.push_back(CreateMockWrite(*req)); |
4267 | 4278 |
4268 // Construct the reply. | 4279 // Construct the reply. |
4269 scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); | 4280 scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); |
4270 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; | 4281 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; |
4271 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 4282 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
4272 scoped_ptr<SpdyFrame> reply( | 4283 scoped_ptr<SpdyFrame> reply( |
4273 spdy_util_.ConstructSpdyFrame(kSynReplyInfo, reply_headers.Pass())); | 4284 spdy_util_.ConstructSpdyFrame(kSynReplyInfo, reply_headers.Pass())); |
4274 | 4285 |
4275 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4286 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
4276 MockRead reads[] = { | 4287 MockRead reads[] = { |
4277 CreateMockRead(*reply, 3), | 4288 CreateMockRead(*reply), |
4278 CreateMockRead(*body, 4), | 4289 CreateMockRead(*body), |
4279 MockRead(ASYNC, 0, 5) // EOF | 4290 MockRead(ASYNC, 0, 0) // EOF |
4280 }; | 4291 }; |
4281 | 4292 |
4282 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4293 DelayedSocketData data(2, reads, arraysize(reads), |
| 4294 vector_as_array(&writes), writes.size()); |
4283 helper.AddData(&data); | 4295 helper.AddData(&data); |
4284 helper.RunDefaultTest(); | 4296 helper.RunDefaultTest(); |
4285 helper.VerifyDataConsumed(); | 4297 helper.VerifyDataConsumed(); |
4286 TransactionHelperResult out = helper.output(); | 4298 TransactionHelperResult out = helper.output(); |
4287 EXPECT_EQ(OK, out.rv); | 4299 EXPECT_EQ(OK, out.rv); |
4288 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4300 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
4289 EXPECT_EQ("hello!", out.response_data); | 4301 EXPECT_EQ("hello!", out.response_data); |
4290 | 4302 |
4291 { | 4303 { |
4292 // Verify we had two persisted settings. | 4304 // Verify we had two persisted settings. |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4776 } | 4788 } |
4777 | 4789 |
4778 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction | 4790 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction |
4779 // on a new connection, if the connection was previously known to be good. | 4791 // on a new connection, if the connection was previously known to be good. |
4780 // This can happen when a server reboots without saying goodbye, or when | 4792 // This can happen when a server reboots without saying goodbye, or when |
4781 // we're behind a NAT that masked the RST. | 4793 // we're behind a NAT that masked the RST. |
4782 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { | 4794 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { |
4783 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4795 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
4784 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4796 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
4785 MockRead reads[] = { | 4797 MockRead reads[] = { |
4786 CreateMockRead(*resp, 1), | 4798 CreateMockRead(*resp, 0), |
4787 CreateMockRead(*body, 2), | 4799 CreateMockRead(*body, 1), |
4788 MockRead(ASYNC, ERR_IO_PENDING, 3), | 4800 MockRead(ASYNC, ERR_IO_PENDING, 2), |
4789 MockRead(ASYNC, ERR_CONNECTION_RESET, 4), | 4801 MockRead(ASYNC, ERR_CONNECTION_RESET, 3), |
4790 }; | 4802 }; |
4791 | 4803 |
4792 MockRead reads2[] = { | 4804 MockRead reads2[] = { |
4793 CreateMockRead(*resp, 1), | 4805 CreateMockRead(*resp, 0), |
4794 CreateMockRead(*body, 2), | 4806 CreateMockRead(*body, 1), |
4795 MockRead(ASYNC, 0, 3) // EOF | 4807 MockRead(ASYNC, 0, 2) // EOF |
4796 }; | 4808 }; |
4797 | 4809 |
4798 // This test has a couple of variants. | 4810 // This test has a couple of variants. |
4799 enum { | 4811 enum { |
4800 // Induce the RST while waiting for our transaction to send. | 4812 // Induce the RST while waiting for our transaction to send. |
4801 VARIANT_RST_DURING_SEND_COMPLETION, | 4813 VARIANT_RST_DURING_SEND_COMPLETION, |
4802 // Induce the RST while waiting for our transaction to read. | 4814 // Induce the RST while waiting for our transaction to read. |
4803 // In this case, the send completed - everything copied into the SNDBUF. | 4815 // In this case, the send completed - everything copied into the SNDBUF. |
4804 VARIANT_RST_DURING_READ_COMPLETION | 4816 VARIANT_RST_DURING_READ_COMPLETION |
4805 }; | 4817 }; |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5492 scoped_ptr<SpdyFrame> stream1_body2( | 5504 scoped_ptr<SpdyFrame> stream1_body2( |
5493 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5505 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
5494 MockRead reads[] = { | 5506 MockRead reads[] = { |
5495 CreateMockRead(*stream1_reply, 1), | 5507 CreateMockRead(*stream1_reply, 1), |
5496 CreateMockRead(*stream1_body, 2), | 5508 CreateMockRead(*stream1_body, 2), |
5497 CreateMockRead(*stream1_headers, 3), | 5509 CreateMockRead(*stream1_headers, 3), |
5498 CreateMockRead(*stream1_body2, 5), | 5510 CreateMockRead(*stream1_body2, 5), |
5499 MockRead(ASYNC, 0, 6) // EOF | 5511 MockRead(ASYNC, 0, 6) // EOF |
5500 }; | 5512 }; |
5501 | 5513 |
5502 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 5514 DelayedSocketData data(1, reads, arraysize(reads), |
| 5515 writes, arraysize(writes)); |
5503 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5516 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
5504 BoundNetLog(), GetParam(), NULL); | 5517 BoundNetLog(), GetParam(), NULL); |
5505 helper.RunToCompletion(&data); | 5518 helper.RunToCompletion(&data); |
5506 TransactionHelperResult out = helper.output(); | 5519 TransactionHelperResult out = helper.output(); |
5507 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 5520 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
5508 } | 5521 } |
5509 | 5522 |
5510 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { | 5523 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { |
5511 // Running these tests via Alt-Svc is too complicated to be worthwhile. | 5524 // Running these tests via Alt-Svc is too complicated to be worthwhile. |
5512 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) | 5525 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6588 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6601 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
6589 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6602 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
6590 new SSLSocketDataProvider(ASYNC, OK)); | 6603 new SSLSocketDataProvider(ASYNC, OK)); |
6591 // Set to TLS_RSA_WITH_NULL_MD5 | 6604 // Set to TLS_RSA_WITH_NULL_MD5 |
6592 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6605 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
6593 | 6606 |
6594 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6607 RunTLSUsageCheckTest(ssl_provider.Pass()); |
6595 } | 6608 } |
6596 | 6609 |
6597 } // namespace net | 6610 } // namespace net |
OLD | NEW |