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, 2), | 2288 CreateMockRead(*resp, 1), |
2289 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause | 2289 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause |
2290 MockRead(ASYNC, reinterpret_cast<const char*>(kGetBodyFrame2), | 2290 MockRead(ASYNC, reinterpret_cast<const char*>(kGetBodyFrame2), |
2291 arraysize(kGetBodyFrame2), 4), | 2291 arraysize(kGetBodyFrame2), 3), |
2292 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause | 2292 MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause |
2293 MockRead(ASYNC, 0, 0, 6), // EOF | 2293 MockRead(ASYNC, 0, 0, 5), // 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 OrderedSocketData data(reads, arraysize(reads), | 2299 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
2300 writes, arraysize(writes)); | |
2301 SequencedSocketData data2(reads2, arraysize(reads2), writes2, | 2300 SequencedSocketData data2(reads2, arraysize(reads2), writes2, |
2302 arraysize(writes2)); | 2301 arraysize(writes2)); |
2303 | 2302 |
2304 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2303 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2305 BoundNetLog(), GetParam(), NULL); | 2304 BoundNetLog(), GetParam(), NULL); |
2306 helper.RunPreTestSetup(); | 2305 helper.RunPreTestSetup(); |
2307 helper.AddData(&data); | 2306 helper.AddData(&data); |
2308 helper.AddData(&data2); | 2307 helper.AddData(&data2); |
2309 HttpNetworkTransaction* trans = helper.trans(); | 2308 HttpNetworkTransaction* trans = helper.trans(); |
2310 | 2309 |
2311 // Start the transaction with basic parameters. | 2310 // Start the transaction with basic parameters. |
2312 TestCompletionCallback callback; | 2311 TestCompletionCallback callback; |
2313 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2312 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2314 EXPECT_EQ(ERR_IO_PENDING, rv); | 2313 EXPECT_EQ(ERR_IO_PENDING, rv); |
2315 rv = callback.WaitForResult(); | 2314 rv = callback.WaitForResult(); |
2316 | 2315 |
2317 const int kSize = 3000; | 2316 const int kSize = 3000; |
2318 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); | 2317 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); |
2319 rv = trans->Read( | 2318 rv = trans->Read( |
2320 buf.get(), kSize, | 2319 buf.get(), kSize, |
2321 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, | 2320 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, |
2322 helper.session(), GURL(GetDefaultUrl()))); | 2321 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) }; | 2336 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
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(), 2), | 2341 CreateMockRead(*resp.get(), 1), |
2342 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause | 2342 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause |
2343 CreateMockRead(*body.get(), 4), | 2343 CreateMockRead(*body.get(), 3), |
2344 MockRead(ASYNC, 0, 0, 5), // EOF | 2344 MockRead(ASYNC, 0, 0, 4), // EOF |
2345 }; | 2345 }; |
2346 | 2346 |
2347 OrderedSocketData data(reads, arraysize(reads), | 2347 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
2348 writes, arraysize(writes)); | |
2349 | 2348 |
2350 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2349 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2351 BoundNetLog(), GetParam(), NULL); | 2350 BoundNetLog(), GetParam(), NULL); |
2352 helper.RunPreTestSetup(); | 2351 helper.RunPreTestSetup(); |
2353 helper.AddData(&data); | 2352 helper.AddData(&data); |
2354 HttpNetworkTransaction* trans = helper.trans(); | 2353 HttpNetworkTransaction* trans = helper.trans(); |
2355 | 2354 |
2356 // Start the transaction with basic parameters. | 2355 // Start the transaction with basic parameters. |
2357 TestCompletionCallback callback; | 2356 TestCompletionCallback callback; |
2358 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2357 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3659 }; | 3658 }; |
3660 char combined_data_frames[100]; | 3659 char combined_data_frames[100]; |
3661 int combined_data_frames_len = | 3660 int combined_data_frames_len = |
3662 CombineFrames(data_frames, arraysize(data_frames), | 3661 CombineFrames(data_frames, arraysize(data_frames), |
3663 combined_data_frames, arraysize(combined_data_frames)); | 3662 combined_data_frames, arraysize(combined_data_frames)); |
3664 scoped_ptr<SpdyFrame> last_frame( | 3663 scoped_ptr<SpdyFrame> last_frame( |
3665 framer.CreateDataFrame(1, "d", 1, DATA_FLAG_FIN)); | 3664 framer.CreateDataFrame(1, "d", 1, DATA_FLAG_FIN)); |
3666 | 3665 |
3667 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3666 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3668 MockRead reads[] = { | 3667 MockRead reads[] = { |
3669 CreateMockRead(*resp), | 3668 CreateMockRead(*resp, 1), |
3670 MockRead(ASYNC, ERR_IO_PENDING), // Force a pause | 3669 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause |
3671 MockRead(ASYNC, combined_data_frames, combined_data_frames_len), | 3670 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), |
3672 MockRead(ASYNC, ERR_IO_PENDING), // Force a pause | 3671 MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause |
3673 CreateMockRead(*last_frame), | 3672 CreateMockRead(*last_frame, 5), |
3674 MockRead(ASYNC, 0, 0) // EOF | 3673 MockRead(ASYNC, 0, 6) // EOF |
3675 }; | 3674 }; |
3676 | 3675 |
3677 DelayedSocketData data(1, reads, arraysize(reads), | 3676 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
3678 writes, arraysize(writes)); | |
3679 | 3677 |
3680 TestCompletionCallback callback; | 3678 TestCompletionCallback callback; |
3681 | 3679 |
3682 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3680 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3683 BoundNetLog(), GetParam(), NULL); | 3681 BoundNetLog(), GetParam(), NULL); |
3684 helper.RunPreTestSetup(); | 3682 helper.RunPreTestSetup(); |
3685 helper.AddData(&data); | 3683 helper.AddData(&data); |
3686 HttpNetworkTransaction* trans = helper.trans(); | 3684 HttpNetworkTransaction* trans = helper.trans(); |
3687 int rv = trans->Start( | 3685 int rv = trans->Start( |
3688 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3686 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3733 } | 3731 } |
3734 | 3732 |
3735 // Verify that basic buffering works; when multiple data frames arrive | 3733 // Verify that basic buffering works; when multiple data frames arrive |
3736 // at the same time, ensure that we don't notify a read completion for | 3734 // at the same time, ensure that we don't notify a read completion for |
3737 // each data frame individually. | 3735 // each data frame individually. |
3738 TEST_P(SpdyNetworkTransactionTest, Buffering) { | 3736 TEST_P(SpdyNetworkTransactionTest, Buffering) { |
3739 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 3737 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
3740 | 3738 |
3741 scoped_ptr<SpdyFrame> req( | 3739 scoped_ptr<SpdyFrame> req( |
3742 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3740 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3743 MockWrite writes[] = { CreateMockWrite(*req) }; | 3741 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
3744 | 3742 |
3745 // 4 data frames in a single read. | 3743 // 4 data frames in a single read. |
3746 scoped_ptr<SpdyFrame> data_frame( | 3744 scoped_ptr<SpdyFrame> data_frame( |
3747 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 3745 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
3748 scoped_ptr<SpdyFrame> data_frame_fin( | 3746 scoped_ptr<SpdyFrame> data_frame_fin( |
3749 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); | 3747 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); |
3750 const SpdyFrame* data_frames[4] = { | 3748 const SpdyFrame* data_frames[4] = { |
3751 data_frame.get(), | 3749 data_frame.get(), |
3752 data_frame.get(), | 3750 data_frame.get(), |
3753 data_frame.get(), | 3751 data_frame.get(), |
3754 data_frame_fin.get() | 3752 data_frame_fin.get() |
3755 }; | 3753 }; |
3756 char combined_data_frames[100]; | 3754 char combined_data_frames[100]; |
3757 int combined_data_frames_len = | 3755 int combined_data_frames_len = |
3758 CombineFrames(data_frames, arraysize(data_frames), | 3756 CombineFrames(data_frames, arraysize(data_frames), |
3759 combined_data_frames, arraysize(combined_data_frames)); | 3757 combined_data_frames, arraysize(combined_data_frames)); |
3760 | 3758 |
3761 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3759 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3762 MockRead reads[] = { | 3760 MockRead reads[] = { |
3763 CreateMockRead(*resp), | 3761 CreateMockRead(*resp, 1), |
3764 MockRead(ASYNC, ERR_IO_PENDING), // Force a pause | 3762 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause |
3765 MockRead(ASYNC, combined_data_frames, combined_data_frames_len), | 3763 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), |
3766 MockRead(ASYNC, 0, 0) // EOF | 3764 MockRead(ASYNC, 0, 4) // EOF |
3767 }; | 3765 }; |
3768 | 3766 |
3769 DelayedSocketData data(1, reads, arraysize(reads), | 3767 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
3770 writes, arraysize(writes)); | |
3771 | 3768 |
3772 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3769 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3773 BoundNetLog(), GetParam(), NULL); | 3770 BoundNetLog(), GetParam(), NULL); |
3774 helper.RunPreTestSetup(); | 3771 helper.RunPreTestSetup(); |
3775 helper.AddData(&data); | 3772 helper.AddData(&data); |
3776 HttpNetworkTransaction* trans = helper.trans(); | 3773 HttpNetworkTransaction* trans = helper.trans(); |
3777 | 3774 |
3778 TestCompletionCallback callback; | 3775 TestCompletionCallback callback; |
3779 int rv = trans->Start( | 3776 int rv = trans->Start( |
3780 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3777 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3912 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 3909 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
3913 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 3910 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
3914 } | 3911 } |
3915 | 3912 |
3916 // Verify the case where we buffer data and close the connection. | 3913 // Verify the case where we buffer data and close the connection. |
3917 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { | 3914 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { |
3918 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 3915 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
3919 | 3916 |
3920 scoped_ptr<SpdyFrame> req( | 3917 scoped_ptr<SpdyFrame> req( |
3921 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3918 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3922 MockWrite writes[] = { CreateMockWrite(*req) }; | 3919 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
3923 | 3920 |
3924 // All data frames in a single read. | 3921 // All data frames in a single read. |
3925 // NOTE: We don't FIN the stream. | 3922 // NOTE: We don't FIN the stream. |
3926 scoped_ptr<SpdyFrame> data_frame( | 3923 scoped_ptr<SpdyFrame> data_frame( |
3927 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 3924 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
3928 const SpdyFrame* data_frames[4] = { | 3925 const SpdyFrame* data_frames[4] = { |
3929 data_frame.get(), | 3926 data_frame.get(), |
3930 data_frame.get(), | 3927 data_frame.get(), |
3931 data_frame.get(), | 3928 data_frame.get(), |
3932 data_frame.get() | 3929 data_frame.get() |
3933 }; | 3930 }; |
3934 char combined_data_frames[100]; | 3931 char combined_data_frames[100]; |
3935 int combined_data_frames_len = | 3932 int combined_data_frames_len = |
3936 CombineFrames(data_frames, arraysize(data_frames), | 3933 CombineFrames(data_frames, arraysize(data_frames), |
3937 combined_data_frames, arraysize(combined_data_frames)); | 3934 combined_data_frames, arraysize(combined_data_frames)); |
3938 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3935 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3939 MockRead reads[] = { | 3936 MockRead reads[] = { |
3940 CreateMockRead(*resp), | 3937 CreateMockRead(*resp, 1), |
3941 MockRead(ASYNC, ERR_IO_PENDING), // Force a wait | 3938 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a wait |
3942 MockRead(ASYNC, combined_data_frames, combined_data_frames_len), | 3939 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), |
3943 MockRead(ASYNC, 0, 0) // EOF | 3940 MockRead(ASYNC, 0, 4) // EOF |
3944 }; | 3941 }; |
3945 | 3942 |
3946 DelayedSocketData data(1, reads, arraysize(reads), | 3943 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
3947 writes, arraysize(writes)); | |
3948 | 3944 |
3949 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3945 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3950 BoundNetLog(), GetParam(), NULL); | 3946 BoundNetLog(), GetParam(), NULL); |
3951 helper.RunPreTestSetup(); | 3947 helper.RunPreTestSetup(); |
3952 helper.AddData(&data); | 3948 helper.AddData(&data); |
3953 HttpNetworkTransaction* trans = helper.trans(); | 3949 HttpNetworkTransaction* trans = helper.trans(); |
3954 | 3950 |
3955 TestCompletionCallback callback; | 3951 TestCompletionCallback callback; |
3956 | 3952 |
3957 int rv = trans->Start( | 3953 int rv = trans->Start( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4005 } | 4001 } |
4006 | 4002 |
4007 // Verify the case where we buffer data and cancel the transaction. | 4003 // Verify the case where we buffer data and cancel the transaction. |
4008 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { | 4004 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { |
4009 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4005 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
4010 | 4006 |
4011 scoped_ptr<SpdyFrame> req( | 4007 scoped_ptr<SpdyFrame> req( |
4012 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4008 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
4013 scoped_ptr<SpdyFrame> rst( | 4009 scoped_ptr<SpdyFrame> rst( |
4014 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 4010 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
4015 MockWrite writes[] = {CreateMockWrite(*req), CreateMockWrite(*rst)}; | 4011 MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4)}; |
4016 | 4012 |
4017 // NOTE: We don't FIN the stream. | 4013 // NOTE: We don't FIN the stream. |
4018 scoped_ptr<SpdyFrame> data_frame( | 4014 scoped_ptr<SpdyFrame> data_frame( |
4019 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 4015 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
4020 | 4016 |
4021 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4017 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
4022 MockRead reads[] = { | 4018 MockRead reads[] = { |
4023 CreateMockRead(*resp), | 4019 CreateMockRead(*resp, 1), |
4024 MockRead(ASYNC, ERR_IO_PENDING), // Force a wait | 4020 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a wait |
4025 CreateMockRead(*data_frame), | 4021 CreateMockRead(*data_frame, 3), |
4026 MockRead(ASYNC, 0, 0) // EOF | 4022 MockRead(ASYNC, 0, 5) // EOF |
4027 }; | 4023 }; |
4028 | 4024 |
4029 DelayedSocketData data(1, reads, arraysize(reads), | 4025 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
4030 writes, arraysize(writes)); | |
4031 | 4026 |
4032 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4027 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
4033 BoundNetLog(), GetParam(), NULL); | 4028 BoundNetLog(), GetParam(), NULL); |
4034 helper.RunPreTestSetup(); | 4029 helper.RunPreTestSetup(); |
4035 helper.AddData(&data); | 4030 helper.AddData(&data); |
4036 HttpNetworkTransaction* trans = helper.trans(); | 4031 HttpNetworkTransaction* trans = helper.trans(); |
4037 TestCompletionCallback callback; | 4032 TestCompletionCallback callback; |
4038 | 4033 |
4039 int rv = trans->Start( | 4034 int rv = trans->Start( |
4040 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4035 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4249 const SettingsMap& settings = | 4244 const SettingsMap& settings = |
4250 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4245 spdy_session_pool->http_server_properties()->GetSpdySettings( |
4251 host_port_pair); | 4246 host_port_pair); |
4252 scoped_ptr<SpdyFrame> settings_frame( | 4247 scoped_ptr<SpdyFrame> settings_frame( |
4253 spdy_util_.ConstructSpdySettings(settings)); | 4248 spdy_util_.ConstructSpdySettings(settings)); |
4254 | 4249 |
4255 // Construct the request. | 4250 // Construct the request. |
4256 scoped_ptr<SpdyFrame> req( | 4251 scoped_ptr<SpdyFrame> req( |
4257 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4252 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
4258 | 4253 |
4259 std::vector<MockWrite> writes; | 4254 MockWrite writes[] = { |
4260 if ((GetParam().protocol >= kProtoSPDY4MinimumVersion) && | 4255 CreateMockWrite(*initial_settings_frame, 0), |
4261 (GetParam().protocol <= kProtoSPDY4MaximumVersion)) { | 4256 CreateMockWrite(*settings_frame, 1), |
4262 writes.push_back( | 4257 CreateMockWrite(*req, 2), |
4263 MockWrite(ASYNC, | 4258 }; |
4264 kHttp2ConnectionHeaderPrefix, | |
4265 kHttp2ConnectionHeaderPrefixSize)); | |
4266 } | |
4267 writes.push_back(CreateMockWrite(*initial_settings_frame)); | |
4268 writes.push_back(CreateMockWrite(*settings_frame)); | |
4269 writes.push_back(CreateMockWrite(*req)); | |
4270 | 4259 |
4271 // Construct the reply. | 4260 // Construct the reply. |
4272 scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); | 4261 scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); |
4273 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; | 4262 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; |
4274 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 4263 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
4275 scoped_ptr<SpdyFrame> reply( | 4264 scoped_ptr<SpdyFrame> reply( |
4276 spdy_util_.ConstructSpdyFrame(kSynReplyInfo, reply_headers.Pass())); | 4265 spdy_util_.ConstructSpdyFrame(kSynReplyInfo, reply_headers.Pass())); |
4277 | 4266 |
4278 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4267 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
4279 MockRead reads[] = { | 4268 MockRead reads[] = { |
4280 CreateMockRead(*reply), | 4269 CreateMockRead(*reply, 3), |
4281 CreateMockRead(*body), | 4270 CreateMockRead(*body, 4), |
4282 MockRead(ASYNC, 0, 0) // EOF | 4271 MockRead(ASYNC, 0, 5) // EOF |
4283 }; | 4272 }; |
4284 | 4273 |
4285 DelayedSocketData data(2, reads, arraysize(reads), | 4274 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
4286 vector_as_array(&writes), writes.size()); | |
4287 helper.AddData(&data); | 4275 helper.AddData(&data); |
4288 helper.RunDefaultTest(); | 4276 helper.RunDefaultTest(); |
4289 helper.VerifyDataConsumed(); | 4277 helper.VerifyDataConsumed(); |
4290 TransactionHelperResult out = helper.output(); | 4278 TransactionHelperResult out = helper.output(); |
4291 EXPECT_EQ(OK, out.rv); | 4279 EXPECT_EQ(OK, out.rv); |
4292 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4280 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
4293 EXPECT_EQ("hello!", out.response_data); | 4281 EXPECT_EQ("hello!", out.response_data); |
4294 | 4282 |
4295 { | 4283 { |
4296 // Verify we had two persisted settings. | 4284 // Verify we had two persisted settings. |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4780 } | 4768 } |
4781 | 4769 |
4782 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction | 4770 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction |
4783 // on a new connection, if the connection was previously known to be good. | 4771 // on a new connection, if the connection was previously known to be good. |
4784 // This can happen when a server reboots without saying goodbye, or when | 4772 // This can happen when a server reboots without saying goodbye, or when |
4785 // we're behind a NAT that masked the RST. | 4773 // we're behind a NAT that masked the RST. |
4786 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { | 4774 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { |
4787 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4775 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
4788 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4776 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
4789 MockRead reads[] = { | 4777 MockRead reads[] = { |
4790 CreateMockRead(*resp, 0), | 4778 CreateMockRead(*resp, 1), |
4791 CreateMockRead(*body, 1), | 4779 CreateMockRead(*body, 2), |
4792 MockRead(ASYNC, ERR_IO_PENDING, 2), | 4780 MockRead(ASYNC, ERR_IO_PENDING, 3), |
4793 MockRead(ASYNC, ERR_CONNECTION_RESET, 3), | 4781 MockRead(ASYNC, ERR_CONNECTION_RESET, 4), |
4794 }; | 4782 }; |
4795 | 4783 |
4796 MockRead reads2[] = { | 4784 MockRead reads2[] = { |
4797 CreateMockRead(*resp, 0), | 4785 CreateMockRead(*resp, 1), |
4798 CreateMockRead(*body, 1), | 4786 CreateMockRead(*body, 2), |
4799 MockRead(ASYNC, 0, 2) // EOF | 4787 MockRead(ASYNC, 0, 3) // EOF |
4800 }; | 4788 }; |
4801 | 4789 |
4802 // This test has a couple of variants. | 4790 // This test has a couple of variants. |
4803 enum { | 4791 enum { |
4804 // Induce the RST while waiting for our transaction to send. | 4792 // Induce the RST while waiting for our transaction to send. |
4805 VARIANT_RST_DURING_SEND_COMPLETION, | 4793 VARIANT_RST_DURING_SEND_COMPLETION, |
4806 // Induce the RST while waiting for our transaction to read. | 4794 // Induce the RST while waiting for our transaction to read. |
4807 // In this case, the send completed - everything copied into the SNDBUF. | 4795 // In this case, the send completed - everything copied into the SNDBUF. |
4808 VARIANT_RST_DURING_READ_COMPLETION | 4796 VARIANT_RST_DURING_READ_COMPLETION |
4809 }; | 4797 }; |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5495 scoped_ptr<SpdyFrame> stream1_body2( | 5483 scoped_ptr<SpdyFrame> stream1_body2( |
5496 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5484 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
5497 MockRead reads[] = { | 5485 MockRead reads[] = { |
5498 CreateMockRead(*stream1_reply, 1), | 5486 CreateMockRead(*stream1_reply, 1), |
5499 CreateMockRead(*stream1_body, 2), | 5487 CreateMockRead(*stream1_body, 2), |
5500 CreateMockRead(*stream1_headers, 3), | 5488 CreateMockRead(*stream1_headers, 3), |
5501 CreateMockRead(*stream1_body2, 5), | 5489 CreateMockRead(*stream1_body2, 5), |
5502 MockRead(ASYNC, 0, 6) // EOF | 5490 MockRead(ASYNC, 0, 6) // EOF |
5503 }; | 5491 }; |
5504 | 5492 |
5505 DelayedSocketData data(1, reads, arraysize(reads), | 5493 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
5506 writes, arraysize(writes)); | |
5507 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5494 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
5508 BoundNetLog(), GetParam(), NULL); | 5495 BoundNetLog(), GetParam(), NULL); |
5509 helper.RunToCompletion(&data); | 5496 helper.RunToCompletion(&data); |
5510 TransactionHelperResult out = helper.output(); | 5497 TransactionHelperResult out = helper.output(); |
5511 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 5498 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
5512 } | 5499 } |
5513 | 5500 |
5514 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { | 5501 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { |
5515 // Running these tests via Alt-Svc is too complicated to be worthwhile. | 5502 // Running these tests via Alt-Svc is too complicated to be worthwhile. |
5516 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) | 5503 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6592 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6579 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
6593 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6580 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
6594 new SSLSocketDataProvider(ASYNC, OK)); | 6581 new SSLSocketDataProvider(ASYNC, OK)); |
6595 // Set to TLS_RSA_WITH_NULL_MD5 | 6582 // Set to TLS_RSA_WITH_NULL_MD5 |
6596 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6583 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
6597 | 6584 |
6598 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6585 RunTLSUsageCheckTest(ssl_provider.Pass()); |
6599 } | 6586 } |
6600 | 6587 |
6601 } // namespace net | 6588 } // namespace net |
OLD | NEW |