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