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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 if (output_.rv != OK) | 263 if (output_.rv != OK) |
264 session_->spdy_session_pool()->CloseCurrentSessions(ERR_ABORTED); | 264 session_->spdy_session_pool()->CloseCurrentSessions(ERR_ABORTED); |
265 } | 265 } |
266 | 266 |
267 // Most tests will want to call this function. In particular, the MockReads | 267 // Most tests will want to call this function. In particular, the MockReads |
268 // should end with an empty read, and that read needs to be processed to | 268 // should end with an empty read, and that read needs to be processed to |
269 // ensure proper deletion of the spdy_session_pool. | 269 // ensure proper deletion of the spdy_session_pool. |
270 void VerifyDataConsumed() { | 270 void VerifyDataConsumed() { |
271 for (DataVector::iterator it = data_vector_.begin(); | 271 for (DataVector::iterator it = data_vector_.begin(); |
272 it != data_vector_.end(); ++it) { | 272 it != data_vector_.end(); ++it) { |
273 EXPECT_TRUE((*it)->AllReadDataConsumed()) | 273 EXPECT_TRUE((*it)->at_read_eof()) << "Read count: " |
274 << "Read count: " << (*it)->read_count() | 274 << (*it)->read_count() |
275 << " Read index: " << (*it)->read_index(); | 275 << " Read index: " |
276 EXPECT_TRUE((*it)->AllWriteDataConsumed()) | 276 << (*it)->read_index(); |
277 << "Write count: " << (*it)->write_count() | 277 EXPECT_TRUE((*it)->at_write_eof()) << "Write count: " |
278 << " Write index: " << (*it)->write_index(); | 278 << (*it)->write_count() |
| 279 << " Write index: " |
| 280 << (*it)->write_index(); |
279 } | 281 } |
280 } | 282 } |
281 | 283 |
282 // Occasionally a test will expect to error out before certain reads are | 284 // Occasionally a test will expect to error out before certain reads are |
283 // processed. In that case we want to explicitly ensure that the reads were | 285 // processed. In that case we want to explicitly ensure that the reads were |
284 // not processed. | 286 // not processed. |
285 void VerifyDataNotConsumed() { | 287 void VerifyDataNotConsumed() { |
286 for (DataVector::iterator it = data_vector_.begin(); | 288 for (DataVector::iterator it = data_vector_.begin(); |
287 it != data_vector_.end(); ++it) { | 289 it != data_vector_.end(); ++it) { |
288 EXPECT_TRUE(!(*it)->AllReadDataConsumed()) | 290 EXPECT_TRUE(!(*it)->at_read_eof()) << "Read count: " |
289 << "Read count: " << (*it)->read_count() | 291 << (*it)->read_count() |
290 << " Read index: " << (*it)->read_index(); | 292 << " Read index: " |
291 EXPECT_TRUE(!(*it)->AllWriteDataConsumed()) | 293 << (*it)->read_index(); |
292 << "Write count: " << (*it)->write_count() | 294 EXPECT_TRUE(!(*it)->at_write_eof()) << "Write count: " |
293 << " Write index: " << (*it)->write_index(); | 295 << (*it)->write_count() |
| 296 << " Write index: " |
| 297 << (*it)->write_index(); |
294 } | 298 } |
295 } | 299 } |
296 | 300 |
297 void RunToCompletion(StaticSocketDataProvider* data) { | 301 void RunToCompletion(StaticSocketDataProvider* data) { |
298 RunPreTestSetup(); | 302 RunPreTestSetup(); |
299 AddData(data); | 303 AddData(data); |
300 RunDefaultTest(); | 304 RunDefaultTest(); |
301 VerifyDataConsumed(); | 305 VerifyDataConsumed(); |
302 } | 306 } |
303 | 307 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 // the results into a single string. | 640 // the results into a single string. |
637 | 641 |
638 // Read the server push body. | 642 // Read the server push body. |
639 std::string result2; | 643 std::string result2; |
640 ReadResult(trans2.get(), data, &result2); | 644 ReadResult(trans2.get(), data, &result2); |
641 // Read the response body. | 645 // Read the response body. |
642 std::string result; | 646 std::string result; |
643 ReadResult(trans, data, &result); | 647 ReadResult(trans, data, &result); |
644 | 648 |
645 // Verify that we consumed all test data. | 649 // Verify that we consumed all test data. |
646 EXPECT_TRUE(data->AllReadDataConsumed()); | 650 EXPECT_TRUE(data->at_read_eof()); |
647 EXPECT_TRUE(data->AllWriteDataConsumed()); | 651 EXPECT_TRUE(data->at_write_eof()); |
648 | 652 |
649 // Verify that the received push data is same as the expected push data. | 653 // Verify that the received push data is same as the expected push data. |
650 EXPECT_EQ(result2.compare(expected), 0) << "Received data: " | 654 EXPECT_EQ(result2.compare(expected), 0) << "Received data: " |
651 << result2 | 655 << result2 |
652 << "||||| Expected data: " | 656 << "||||| Expected data: " |
653 << expected; | 657 << expected; |
654 | 658 |
655 // Verify the SYN_REPLY. | 659 // Verify the SYN_REPLY. |
656 // Copy the response info, because trans goes away. | 660 // Copy the response info, because trans goes away. |
657 *response = *trans->GetResponseInfo(); | 661 *response = *trans->GetResponseInfo(); |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2477 EXPECT_EQ(1, d.received_redirect_count()); | 2481 EXPECT_EQ(1, d.received_redirect_count()); |
2478 | 2482 |
2479 r->FollowDeferredRedirect(); | 2483 r->FollowDeferredRedirect(); |
2480 base::RunLoop().Run(); | 2484 base::RunLoop().Run(); |
2481 EXPECT_EQ(1, d.response_started_count()); | 2485 EXPECT_EQ(1, d.response_started_count()); |
2482 EXPECT_FALSE(d.received_data_before_response()); | 2486 EXPECT_FALSE(d.received_data_before_response()); |
2483 EXPECT_EQ(URLRequestStatus::SUCCESS, r->status().status()); | 2487 EXPECT_EQ(URLRequestStatus::SUCCESS, r->status().status()); |
2484 std::string contents("hello!"); | 2488 std::string contents("hello!"); |
2485 EXPECT_EQ(contents, d.data_received()); | 2489 EXPECT_EQ(contents, d.data_received()); |
2486 } | 2490 } |
2487 EXPECT_TRUE(data.AllReadDataConsumed()); | 2491 EXPECT_TRUE(data.at_read_eof()); |
2488 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2492 EXPECT_TRUE(data.at_write_eof()); |
2489 EXPECT_TRUE(data2.AllReadDataConsumed()); | 2493 EXPECT_TRUE(data2.at_read_eof()); |
2490 EXPECT_TRUE(data2.AllWriteDataConsumed()); | 2494 EXPECT_TRUE(data2.at_write_eof()); |
2491 } | 2495 } |
2492 | 2496 |
2493 // Send a spdy request to www.example.org. Get a pushed stream that redirects to | 2497 // Send a spdy request to www.example.org. Get a pushed stream that redirects to |
2494 // www.foo.com. | 2498 // www.foo.com. |
2495 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) { | 2499 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) { |
2496 scoped_ptr<SpdyHeaderBlock> headers( | 2500 scoped_ptr<SpdyHeaderBlock> headers( |
2497 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); | 2501 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); |
2498 (*headers)["user-agent"] = ""; | 2502 (*headers)["user-agent"] = ""; |
2499 (*headers)["accept-encoding"] = "gzip, deflate"; | 2503 (*headers)["accept-encoding"] = "gzip, deflate"; |
2500 | 2504 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 r2->FollowDeferredRedirect(); | 2576 r2->FollowDeferredRedirect(); |
2573 base::RunLoop().Run(); | 2577 base::RunLoop().Run(); |
2574 EXPECT_EQ(1, d2.response_started_count()); | 2578 EXPECT_EQ(1, d2.response_started_count()); |
2575 EXPECT_FALSE(d2.received_data_before_response()); | 2579 EXPECT_FALSE(d2.received_data_before_response()); |
2576 EXPECT_EQ(URLRequestStatus::SUCCESS, r2->status().status()); | 2580 EXPECT_EQ(URLRequestStatus::SUCCESS, r2->status().status()); |
2577 std::string contents2("hello!"); | 2581 std::string contents2("hello!"); |
2578 EXPECT_EQ(contents2, d2.data_received()); | 2582 EXPECT_EQ(contents2, d2.data_received()); |
2579 } | 2583 } |
2580 data.CompleteRead(); | 2584 data.CompleteRead(); |
2581 data2.CompleteRead(); | 2585 data2.CompleteRead(); |
2582 EXPECT_TRUE(data.AllReadDataConsumed()); | 2586 EXPECT_TRUE(data.at_read_eof()); |
2583 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2587 EXPECT_TRUE(data.at_write_eof()); |
2584 EXPECT_TRUE(data2.AllReadDataConsumed()); | 2588 EXPECT_TRUE(data2.at_read_eof()); |
2585 EXPECT_TRUE(data2.AllWriteDataConsumed()); | 2589 EXPECT_TRUE(data2.at_write_eof()); |
2586 } | 2590 } |
2587 | 2591 |
2588 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { | 2592 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { |
2589 scoped_ptr<SpdyFrame> stream1_syn( | 2593 scoped_ptr<SpdyFrame> stream1_syn( |
2590 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2594 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
2591 scoped_ptr<SpdyFrame> stream1_body( | 2595 scoped_ptr<SpdyFrame> stream1_body( |
2592 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2596 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
2593 MockWrite writes[] = { | 2597 MockWrite writes[] = { |
2594 CreateMockWrite(*stream1_syn, 1), | 2598 CreateMockWrite(*stream1_syn, 1), |
2595 }; | 2599 }; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2750 | 2754 |
2751 // Start the transaction with basic parameters. | 2755 // Start the transaction with basic parameters. |
2752 TestCompletionCallback callback; | 2756 TestCompletionCallback callback; |
2753 int rv = trans->Start( | 2757 int rv = trans->Start( |
2754 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2758 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
2755 EXPECT_EQ(ERR_IO_PENDING, rv); | 2759 EXPECT_EQ(ERR_IO_PENDING, rv); |
2756 rv = callback.WaitForResult(); | 2760 rv = callback.WaitForResult(); |
2757 EXPECT_EQ(OK, rv); | 2761 EXPECT_EQ(OK, rv); |
2758 | 2762 |
2759 // Verify that we consumed all test data. | 2763 // Verify that we consumed all test data. |
2760 EXPECT_TRUE(data.AllReadDataConsumed()) | 2764 EXPECT_TRUE(data.at_read_eof()) << "Read count: " |
2761 << "Read count: " << data.read_count() | 2765 << data.read_count() |
2762 << " Read index: " << data.read_index(); | 2766 << " Read index: " |
2763 EXPECT_TRUE(data.AllWriteDataConsumed()) | 2767 << data.read_index(); |
2764 << "Write count: " << data.write_count() | 2768 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
2765 << " Write index: " << data.write_index(); | 2769 << data.write_count() |
| 2770 << " Write index: " |
| 2771 << data.write_index(); |
2766 | 2772 |
2767 // Verify the SYN_REPLY. | 2773 // Verify the SYN_REPLY. |
2768 HttpResponseInfo response = *trans->GetResponseInfo(); | 2774 HttpResponseInfo response = *trans->GetResponseInfo(); |
2769 EXPECT_TRUE(response.headers.get() != NULL); | 2775 EXPECT_TRUE(response.headers.get() != NULL); |
2770 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2776 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2771 } | 2777 } |
2772 | 2778 |
2773 // Verify that we don't leak streams and that we properly send a reset | 2779 // Verify that we don't leak streams and that we properly send a reset |
2774 // if the server pushes the same stream twice. | 2780 // if the server pushes the same stream twice. |
2775 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) { | 2781 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2973 | 2979 |
2974 // Start the transaction with basic parameters. | 2980 // Start the transaction with basic parameters. |
2975 TestCompletionCallback callback; | 2981 TestCompletionCallback callback; |
2976 int rv = trans->Start( | 2982 int rv = trans->Start( |
2977 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2983 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
2978 EXPECT_EQ(ERR_IO_PENDING, rv); | 2984 EXPECT_EQ(ERR_IO_PENDING, rv); |
2979 rv = callback.WaitForResult(); | 2985 rv = callback.WaitForResult(); |
2980 EXPECT_EQ(OK, rv); | 2986 EXPECT_EQ(OK, rv); |
2981 | 2987 |
2982 // Verify that we consumed all test data. | 2988 // Verify that we consumed all test data. |
2983 EXPECT_TRUE(data.AllReadDataConsumed()) | 2989 EXPECT_TRUE(data.at_read_eof()) << "Read count: " |
2984 << "Read count: " << data.read_count() | 2990 << data.read_count() |
2985 << " Read index: " << data.read_index(); | 2991 << " Read index: " |
2986 EXPECT_TRUE(data.AllWriteDataConsumed()) | 2992 << data.read_index(); |
2987 << "Write count: " << data.write_count() | 2993 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
2988 << " Write index: " << data.write_index(); | 2994 << data.write_count() |
| 2995 << " Write index: " |
| 2996 << data.write_index(); |
2989 | 2997 |
2990 // Verify the SYN_REPLY. | 2998 // Verify the SYN_REPLY. |
2991 HttpResponseInfo response = *trans->GetResponseInfo(); | 2999 HttpResponseInfo response = *trans->GetResponseInfo(); |
2992 EXPECT_TRUE(response.headers.get() != NULL); | 3000 EXPECT_TRUE(response.headers.get() != NULL); |
2993 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3001 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2994 } | 3002 } |
2995 | 3003 |
2996 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { | 3004 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { |
2997 scoped_ptr<SpdyFrame> stream1_syn( | 3005 scoped_ptr<SpdyFrame> stream1_syn( |
2998 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3006 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
(...skipping 29 matching lines...) Expand all Loading... |
3028 | 3036 |
3029 // Start the transaction with basic parameters. | 3037 // Start the transaction with basic parameters. |
3030 TestCompletionCallback callback; | 3038 TestCompletionCallback callback; |
3031 int rv = trans->Start( | 3039 int rv = trans->Start( |
3032 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3040 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
3033 EXPECT_EQ(ERR_IO_PENDING, rv); | 3041 EXPECT_EQ(ERR_IO_PENDING, rv); |
3034 rv = callback.WaitForResult(); | 3042 rv = callback.WaitForResult(); |
3035 EXPECT_EQ(OK, rv); | 3043 EXPECT_EQ(OK, rv); |
3036 | 3044 |
3037 // Verify that we consumed all test data. | 3045 // Verify that we consumed all test data. |
3038 EXPECT_TRUE(data.AllReadDataConsumed()) | 3046 EXPECT_TRUE(data.at_read_eof()) << "Read count: " |
3039 << "Read count: " << data.read_count() | 3047 << data.read_count() |
3040 << " Read index: " << data.read_index(); | 3048 << " Read index: " |
3041 EXPECT_TRUE(data.AllWriteDataConsumed()) | 3049 << data.read_index(); |
3042 << "Write count: " << data.write_count() | 3050 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
3043 << " Write index: " << data.write_index(); | 3051 << data.write_count() |
| 3052 << " Write index: " |
| 3053 << data.write_index(); |
3044 | 3054 |
3045 // Verify the SYN_REPLY. | 3055 // Verify the SYN_REPLY. |
3046 HttpResponseInfo response = *trans->GetResponseInfo(); | 3056 HttpResponseInfo response = *trans->GetResponseInfo(); |
3047 EXPECT_TRUE(response.headers.get() != NULL); | 3057 EXPECT_TRUE(response.headers.get() != NULL); |
3048 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3058 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3049 } | 3059 } |
3050 | 3060 |
3051 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) { | 3061 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) { |
3052 scoped_ptr<SpdyFrame> stream1_syn( | 3062 scoped_ptr<SpdyFrame> stream1_syn( |
3053 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3063 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3086 HttpNetworkTransaction* trans = helper.trans(); | 3096 HttpNetworkTransaction* trans = helper.trans(); |
3087 | 3097 |
3088 // Start the transaction with basic parameters. | 3098 // Start the transaction with basic parameters. |
3089 TestCompletionCallback callback; | 3099 TestCompletionCallback callback; |
3090 int rv = trans->Start( | 3100 int rv = trans->Start( |
3091 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3101 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
3092 EXPECT_EQ(ERR_IO_PENDING, rv); | 3102 EXPECT_EQ(ERR_IO_PENDING, rv); |
3093 rv = callback.WaitForResult(); | 3103 rv = callback.WaitForResult(); |
3094 EXPECT_EQ(OK, rv); | 3104 EXPECT_EQ(OK, rv); |
3095 // Verify that we consumed all test data. | 3105 // Verify that we consumed all test data. |
3096 EXPECT_TRUE(data.AllReadDataConsumed()) | 3106 EXPECT_TRUE(data.at_read_eof()) << "Read count: " |
3097 << "Read count: " << data.read_count() | 3107 << data.read_count() |
3098 << " Read index: " << data.read_index(); | 3108 << " Read index: " |
3099 EXPECT_TRUE(data.AllWriteDataConsumed()) | 3109 << data.read_index(); |
3100 << "Write count: " << data.write_count() | 3110 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
3101 << " Write index: " << data.write_index(); | 3111 << data.write_count() |
| 3112 << " Write index: " |
| 3113 << data.write_index(); |
3102 | 3114 |
3103 // Verify the SYN_REPLY. | 3115 // Verify the SYN_REPLY. |
3104 HttpResponseInfo response = *trans->GetResponseInfo(); | 3116 HttpResponseInfo response = *trans->GetResponseInfo(); |
3105 EXPECT_TRUE(response.headers.get() != NULL); | 3117 EXPECT_TRUE(response.headers.get() != NULL); |
3106 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3118 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3107 } | 3119 } |
3108 | 3120 |
3109 // Verify that various SynReply headers parse correctly through the | 3121 // Verify that various SynReply headers parse correctly through the |
3110 // HTTP layer. | 3122 // HTTP layer. |
3111 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { | 3123 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3560 writes, arraysize(writes)); | 3572 writes, arraysize(writes)); |
3561 | 3573 |
3562 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3574 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3563 BoundNetLog(), GetParam(), NULL); | 3575 BoundNetLog(), GetParam(), NULL); |
3564 helper.SetDeterministic(); | 3576 helper.SetDeterministic(); |
3565 helper.RunPreTestSetup(); | 3577 helper.RunPreTestSetup(); |
3566 helper.AddDeterministicData(&data); | 3578 helper.AddDeterministicData(&data); |
3567 EXPECT_TRUE(helper.StartDefaultTest()); | 3579 EXPECT_TRUE(helper.StartDefaultTest()); |
3568 data.RunFor(2); | 3580 data.RunFor(2); |
3569 helper.FinishDefaultTest(); | 3581 helper.FinishDefaultTest(); |
3570 EXPECT_TRUE(data.AllWriteDataConsumed()); | 3582 EXPECT_TRUE(data.at_write_eof()); |
3571 EXPECT_TRUE(!data.AllReadDataConsumed()); | 3583 EXPECT_TRUE(!data.at_read_eof()); |
3572 TransactionHelperResult out = helper.output(); | 3584 TransactionHelperResult out = helper.output(); |
3573 EXPECT_EQ(ERR_FAILED, out.rv); | 3585 EXPECT_EQ(ERR_FAILED, out.rv); |
3574 } | 3586 } |
3575 | 3587 |
3576 // Test that partial writes work. | 3588 // Test that partial writes work. |
3577 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { | 3589 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { |
3578 // Chop the SYN_STREAM frame into 5 chunks. | 3590 // Chop the SYN_STREAM frame into 5 chunks. |
3579 scoped_ptr<SpdyFrame> req( | 3591 scoped_ptr<SpdyFrame> req( |
3580 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3592 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3581 const int kChunks = 5; | 3593 const int kChunks = 5; |
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5259 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5271 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5260 | 5272 |
5261 // Verify the pushed stream. | 5273 // Verify the pushed stream. |
5262 EXPECT_TRUE(response2.headers.get() != NULL); | 5274 EXPECT_TRUE(response2.headers.get() != NULL); |
5263 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5275 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
5264 | 5276 |
5265 // Read the final EOF (which will close the session) | 5277 // Read the final EOF (which will close the session) |
5266 data.RunFor(1); | 5278 data.RunFor(1); |
5267 | 5279 |
5268 // Verify that we consumed all test data. | 5280 // Verify that we consumed all test data. |
5269 EXPECT_TRUE(data.AllReadDataConsumed()); | 5281 EXPECT_TRUE(data.at_read_eof()); |
5270 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5282 EXPECT_TRUE(data.at_write_eof()); |
5271 } | 5283 } |
5272 | 5284 |
5273 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames | 5285 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames |
5274 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { | 5286 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { |
5275 // We push a stream and attempt to claim it before the headers come down. | 5287 // We push a stream and attempt to claim it before the headers come down. |
5276 scoped_ptr<SpdyFrame> stream1_syn( | 5288 scoped_ptr<SpdyFrame> stream1_syn( |
5277 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5289 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
5278 scoped_ptr<SpdyFrame> stream1_body( | 5290 scoped_ptr<SpdyFrame> stream1_body( |
5279 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5291 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
5280 MockWrite writes[] = { | 5292 MockWrite writes[] = { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5399 // Verify we got all the headers from all header blocks. | 5411 // Verify we got all the headers from all header blocks. |
5400 if (spdy_util_.spdy_version() < SPDY4) | 5412 if (spdy_util_.spdy_version() < SPDY4) |
5401 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta")); | 5413 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta")); |
5402 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); | 5414 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); |
5403 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); | 5415 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); |
5404 | 5416 |
5405 // Read the final EOF (which will close the session) | 5417 // Read the final EOF (which will close the session) |
5406 data.RunFor(1); | 5418 data.RunFor(1); |
5407 | 5419 |
5408 // Verify that we consumed all test data. | 5420 // Verify that we consumed all test data. |
5409 EXPECT_TRUE(data.AllReadDataConsumed()); | 5421 EXPECT_TRUE(data.at_read_eof()); |
5410 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5422 EXPECT_TRUE(data.at_write_eof()); |
5411 } | 5423 } |
5412 | 5424 |
5413 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { | 5425 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { |
5414 // We push a stream and attempt to claim it before the headers come down. | 5426 // We push a stream and attempt to claim it before the headers come down. |
5415 scoped_ptr<SpdyFrame> stream1_syn( | 5427 scoped_ptr<SpdyFrame> stream1_syn( |
5416 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5428 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
5417 scoped_ptr<SpdyFrame> stream1_body( | 5429 scoped_ptr<SpdyFrame> stream1_body( |
5418 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5430 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
5419 MockWrite writes[] = { | 5431 MockWrite writes[] = { |
5420 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5432 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5506 VerifyStreamsClosed(helper); | 5518 VerifyStreamsClosed(helper); |
5507 | 5519 |
5508 // Verify the SYN_REPLY. | 5520 // Verify the SYN_REPLY. |
5509 EXPECT_TRUE(response.headers.get() != NULL); | 5521 EXPECT_TRUE(response.headers.get() != NULL); |
5510 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5522 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5511 | 5523 |
5512 // Read the final EOF (which will close the session). | 5524 // Read the final EOF (which will close the session). |
5513 data.RunFor(1); | 5525 data.RunFor(1); |
5514 | 5526 |
5515 // Verify that we consumed all test data. | 5527 // Verify that we consumed all test data. |
5516 EXPECT_TRUE(data.AllReadDataConsumed()); | 5528 EXPECT_TRUE(data.at_read_eof()); |
5517 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5529 EXPECT_TRUE(data.at_write_eof()); |
5518 } | 5530 } |
5519 | 5531 |
5520 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { | 5532 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { |
5521 scoped_ptr<SpdyFrame> req( | 5533 scoped_ptr<SpdyFrame> req( |
5522 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5534 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
5523 scoped_ptr<SpdyFrame> rst( | 5535 scoped_ptr<SpdyFrame> rst( |
5524 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 5536 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
5525 MockWrite writes[] = { | 5537 MockWrite writes[] = { |
5526 CreateMockWrite(*req), CreateMockWrite(*rst), | 5538 CreateMockWrite(*req), CreateMockWrite(*rst), |
5527 }; | 5539 }; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5695 | 5707 |
5696 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5708 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5697 EXPECT_EQ(ERR_IO_PENDING, rv); | 5709 EXPECT_EQ(ERR_IO_PENDING, rv); |
5698 rv = callback.WaitForResult(); | 5710 rv = callback.WaitForResult(); |
5699 | 5711 |
5700 // Read the response body. | 5712 // Read the response body. |
5701 std::string result; | 5713 std::string result; |
5702 ReadResult(trans, &data, &result); | 5714 ReadResult(trans, &data, &result); |
5703 | 5715 |
5704 // Verify that we consumed all test data. | 5716 // Verify that we consumed all test data. |
5705 EXPECT_TRUE(data.AllReadDataConsumed()); | 5717 EXPECT_TRUE(data.at_read_eof()); |
5706 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5718 EXPECT_TRUE(data.at_write_eof()); |
5707 | 5719 |
5708 // Verify the SYN_REPLY. | 5720 // Verify the SYN_REPLY. |
5709 // Copy the response info, because trans goes away. | 5721 // Copy the response info, because trans goes away. |
5710 response = *trans->GetResponseInfo(); | 5722 response = *trans->GetResponseInfo(); |
5711 | 5723 |
5712 VerifyStreamsClosed(helper); | 5724 VerifyStreamsClosed(helper); |
5713 | 5725 |
5714 // Verify the SYN_REPLY. | 5726 // Verify the SYN_REPLY. |
5715 EXPECT_TRUE(response.headers.get() != NULL); | 5727 EXPECT_TRUE(response.headers.get() != NULL); |
5716 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5728 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5751 | 5763 |
5752 // Start the transaction with basic parameters. | 5764 // Start the transaction with basic parameters. |
5753 TestCompletionCallback callback; | 5765 TestCompletionCallback callback; |
5754 int rv = trans->Start( | 5766 int rv = trans->Start( |
5755 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5767 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
5756 EXPECT_EQ(ERR_IO_PENDING, rv); | 5768 EXPECT_EQ(ERR_IO_PENDING, rv); |
5757 rv = callback.WaitForResult(); | 5769 rv = callback.WaitForResult(); |
5758 EXPECT_EQ(OK, rv); | 5770 EXPECT_EQ(OK, rv); |
5759 | 5771 |
5760 // Verify that we consumed all test data. | 5772 // Verify that we consumed all test data. |
5761 EXPECT_TRUE(data.AllReadDataConsumed()) | 5773 EXPECT_TRUE(data.at_read_eof()) << "Read count: " |
5762 << "Read count: " << data.read_count() | 5774 << data.read_count() |
5763 << " Read index: " << data.read_index(); | 5775 << " Read index: " |
5764 EXPECT_TRUE(data.AllWriteDataConsumed()) | 5776 << data.read_index(); |
5765 << "Write count: " << data.write_count() | 5777 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
5766 << " Write index: " << data.write_index(); | 5778 << data.write_count() |
| 5779 << " Write index: " |
| 5780 << data.write_index(); |
5767 | 5781 |
5768 // Verify the SYN_REPLY. | 5782 // Verify the SYN_REPLY. |
5769 HttpResponseInfo response = *trans->GetResponseInfo(); | 5783 HttpResponseInfo response = *trans->GetResponseInfo(); |
5770 EXPECT_TRUE(response.headers.get() != NULL); | 5784 EXPECT_TRUE(response.headers.get() != NULL); |
5771 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5785 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5772 } | 5786 } |
5773 | 5787 |
5774 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { | 5788 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { |
5775 // This first request will start to establish the SpdySession. | 5789 // This first request will start to establish the SpdySession. |
5776 // Then we will start the second (MEDIUM priority) and then third | 5790 // Then we will start the second (MEDIUM priority) and then third |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6688 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6702 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
6689 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6703 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
6690 new SSLSocketDataProvider(ASYNC, OK)); | 6704 new SSLSocketDataProvider(ASYNC, OK)); |
6691 // Set to TLS_RSA_WITH_NULL_MD5 | 6705 // Set to TLS_RSA_WITH_NULL_MD5 |
6692 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6706 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
6693 | 6707 |
6694 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6708 RunTLSUsageCheckTest(ssl_provider.Pass()); |
6695 } | 6709 } |
6696 | 6710 |
6697 } // namespace net | 6711 } // namespace net |
OLD | NEW |