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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3552 writes, arraysize(writes)); | 3564 writes, arraysize(writes)); |
3553 | 3565 |
3554 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3566 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3555 BoundNetLog(), GetParam(), NULL); | 3567 BoundNetLog(), GetParam(), NULL); |
3556 helper.SetDeterministic(); | 3568 helper.SetDeterministic(); |
3557 helper.RunPreTestSetup(); | 3569 helper.RunPreTestSetup(); |
3558 helper.AddDeterministicData(&data); | 3570 helper.AddDeterministicData(&data); |
3559 EXPECT_TRUE(helper.StartDefaultTest()); | 3571 EXPECT_TRUE(helper.StartDefaultTest()); |
3560 data.RunFor(2); | 3572 data.RunFor(2); |
3561 helper.FinishDefaultTest(); | 3573 helper.FinishDefaultTest(); |
3562 EXPECT_TRUE(data.AllWriteDataConsumed()); | 3574 EXPECT_TRUE(data.at_write_eof()); |
3563 EXPECT_TRUE(!data.AllReadDataConsumed()); | 3575 EXPECT_TRUE(!data.at_read_eof()); |
3564 TransactionHelperResult out = helper.output(); | 3576 TransactionHelperResult out = helper.output(); |
3565 EXPECT_EQ(ERR_FAILED, out.rv); | 3577 EXPECT_EQ(ERR_FAILED, out.rv); |
3566 } | 3578 } |
3567 | 3579 |
3568 // Test that partial writes work. | 3580 // Test that partial writes work. |
3569 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { | 3581 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { |
3570 // Chop the SYN_STREAM frame into 5 chunks. | 3582 // Chop the SYN_STREAM frame into 5 chunks. |
3571 scoped_ptr<SpdyFrame> req( | 3583 scoped_ptr<SpdyFrame> req( |
3572 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3584 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3573 const int kChunks = 5; | 3585 const int kChunks = 5; |
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5251 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5263 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5252 | 5264 |
5253 // Verify the pushed stream. | 5265 // Verify the pushed stream. |
5254 EXPECT_TRUE(response2.headers.get() != NULL); | 5266 EXPECT_TRUE(response2.headers.get() != NULL); |
5255 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5267 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
5256 | 5268 |
5257 // Read the final EOF (which will close the session) | 5269 // Read the final EOF (which will close the session) |
5258 data.RunFor(1); | 5270 data.RunFor(1); |
5259 | 5271 |
5260 // Verify that we consumed all test data. | 5272 // Verify that we consumed all test data. |
5261 EXPECT_TRUE(data.AllReadDataConsumed()); | 5273 EXPECT_TRUE(data.at_read_eof()); |
5262 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5274 EXPECT_TRUE(data.at_write_eof()); |
5263 } | 5275 } |
5264 | 5276 |
5265 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames | 5277 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames |
5266 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { | 5278 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { |
5267 // We push a stream and attempt to claim it before the headers come down. | 5279 // We push a stream and attempt to claim it before the headers come down. |
5268 scoped_ptr<SpdyFrame> stream1_syn( | 5280 scoped_ptr<SpdyFrame> stream1_syn( |
5269 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5281 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
5270 scoped_ptr<SpdyFrame> stream1_body( | 5282 scoped_ptr<SpdyFrame> stream1_body( |
5271 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5283 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
5272 MockWrite writes[] = { | 5284 MockWrite writes[] = { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5391 // Verify we got all the headers from all header blocks. | 5403 // Verify we got all the headers from all header blocks. |
5392 if (spdy_util_.spdy_version() < SPDY4) | 5404 if (spdy_util_.spdy_version() < SPDY4) |
5393 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta")); | 5405 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta")); |
5394 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); | 5406 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); |
5395 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); | 5407 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); |
5396 | 5408 |
5397 // Read the final EOF (which will close the session) | 5409 // Read the final EOF (which will close the session) |
5398 data.RunFor(1); | 5410 data.RunFor(1); |
5399 | 5411 |
5400 // Verify that we consumed all test data. | 5412 // Verify that we consumed all test data. |
5401 EXPECT_TRUE(data.AllReadDataConsumed()); | 5413 EXPECT_TRUE(data.at_read_eof()); |
5402 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5414 EXPECT_TRUE(data.at_write_eof()); |
5403 } | 5415 } |
5404 | 5416 |
5405 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { | 5417 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { |
5406 // We push a stream and attempt to claim it before the headers come down. | 5418 // We push a stream and attempt to claim it before the headers come down. |
5407 scoped_ptr<SpdyFrame> stream1_syn( | 5419 scoped_ptr<SpdyFrame> stream1_syn( |
5408 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5420 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
5409 scoped_ptr<SpdyFrame> stream1_body( | 5421 scoped_ptr<SpdyFrame> stream1_body( |
5410 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5422 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
5411 MockWrite writes[] = { | 5423 MockWrite writes[] = { |
5412 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5424 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5498 VerifyStreamsClosed(helper); | 5510 VerifyStreamsClosed(helper); |
5499 | 5511 |
5500 // Verify the SYN_REPLY. | 5512 // Verify the SYN_REPLY. |
5501 EXPECT_TRUE(response.headers.get() != NULL); | 5513 EXPECT_TRUE(response.headers.get() != NULL); |
5502 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5514 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5503 | 5515 |
5504 // Read the final EOF (which will close the session). | 5516 // Read the final EOF (which will close the session). |
5505 data.RunFor(1); | 5517 data.RunFor(1); |
5506 | 5518 |
5507 // Verify that we consumed all test data. | 5519 // Verify that we consumed all test data. |
5508 EXPECT_TRUE(data.AllReadDataConsumed()); | 5520 EXPECT_TRUE(data.at_read_eof()); |
5509 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5521 EXPECT_TRUE(data.at_write_eof()); |
5510 } | 5522 } |
5511 | 5523 |
5512 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { | 5524 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { |
5513 scoped_ptr<SpdyFrame> req( | 5525 scoped_ptr<SpdyFrame> req( |
5514 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5526 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
5515 scoped_ptr<SpdyFrame> rst( | 5527 scoped_ptr<SpdyFrame> rst( |
5516 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 5528 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
5517 MockWrite writes[] = { | 5529 MockWrite writes[] = { |
5518 CreateMockWrite(*req), CreateMockWrite(*rst), | 5530 CreateMockWrite(*req), CreateMockWrite(*rst), |
5519 }; | 5531 }; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5687 | 5699 |
5688 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5700 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5689 EXPECT_EQ(ERR_IO_PENDING, rv); | 5701 EXPECT_EQ(ERR_IO_PENDING, rv); |
5690 rv = callback.WaitForResult(); | 5702 rv = callback.WaitForResult(); |
5691 | 5703 |
5692 // Read the response body. | 5704 // Read the response body. |
5693 std::string result; | 5705 std::string result; |
5694 ReadResult(trans, &data, &result); | 5706 ReadResult(trans, &data, &result); |
5695 | 5707 |
5696 // Verify that we consumed all test data. | 5708 // Verify that we consumed all test data. |
5697 EXPECT_TRUE(data.AllReadDataConsumed()); | 5709 EXPECT_TRUE(data.at_read_eof()); |
5698 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5710 EXPECT_TRUE(data.at_write_eof()); |
5699 | 5711 |
5700 // Verify the SYN_REPLY. | 5712 // Verify the SYN_REPLY. |
5701 // Copy the response info, because trans goes away. | 5713 // Copy the response info, because trans goes away. |
5702 response = *trans->GetResponseInfo(); | 5714 response = *trans->GetResponseInfo(); |
5703 | 5715 |
5704 VerifyStreamsClosed(helper); | 5716 VerifyStreamsClosed(helper); |
5705 | 5717 |
5706 // Verify the SYN_REPLY. | 5718 // Verify the SYN_REPLY. |
5707 EXPECT_TRUE(response.headers.get() != NULL); | 5719 EXPECT_TRUE(response.headers.get() != NULL); |
5708 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5720 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5743 | 5755 |
5744 // Start the transaction with basic parameters. | 5756 // Start the transaction with basic parameters. |
5745 TestCompletionCallback callback; | 5757 TestCompletionCallback callback; |
5746 int rv = trans->Start( | 5758 int rv = trans->Start( |
5747 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5759 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
5748 EXPECT_EQ(ERR_IO_PENDING, rv); | 5760 EXPECT_EQ(ERR_IO_PENDING, rv); |
5749 rv = callback.WaitForResult(); | 5761 rv = callback.WaitForResult(); |
5750 EXPECT_EQ(OK, rv); | 5762 EXPECT_EQ(OK, rv); |
5751 | 5763 |
5752 // Verify that we consumed all test data. | 5764 // Verify that we consumed all test data. |
5753 EXPECT_TRUE(data.AllReadDataConsumed()) | 5765 EXPECT_TRUE(data.at_read_eof()) << "Read count: " |
5754 << "Read count: " << data.read_count() | 5766 << data.read_count() |
5755 << " Read index: " << data.read_index(); | 5767 << " Read index: " |
5756 EXPECT_TRUE(data.AllWriteDataConsumed()) | 5768 << data.read_index(); |
5757 << "Write count: " << data.write_count() | 5769 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
5758 << " Write index: " << data.write_index(); | 5770 << data.write_count() |
| 5771 << " Write index: " |
| 5772 << data.write_index(); |
5759 | 5773 |
5760 // Verify the SYN_REPLY. | 5774 // Verify the SYN_REPLY. |
5761 HttpResponseInfo response = *trans->GetResponseInfo(); | 5775 HttpResponseInfo response = *trans->GetResponseInfo(); |
5762 EXPECT_TRUE(response.headers.get() != NULL); | 5776 EXPECT_TRUE(response.headers.get() != NULL); |
5763 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5777 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5764 } | 5778 } |
5765 | 5779 |
5766 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { | 5780 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { |
5767 // This first request will start to establish the SpdySession. | 5781 // This first request will start to establish the SpdySession. |
5768 // Then we will start the second (MEDIUM priority) and then third | 5782 // Then we will start the second (MEDIUM priority) and then third |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6680 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6694 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
6681 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6695 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
6682 new SSLSocketDataProvider(ASYNC, OK)); | 6696 new SSLSocketDataProvider(ASYNC, OK)); |
6683 // Set to TLS_RSA_WITH_NULL_MD5 | 6697 // Set to TLS_RSA_WITH_NULL_MD5 |
6684 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6698 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
6685 | 6699 |
6686 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6700 RunTLSUsageCheckTest(ssl_provider.Pass()); |
6687 } | 6701 } |
6688 | 6702 |
6689 } // namespace net | 6703 } // namespace net |
OLD | NEW |