| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 void FinishDefaultTestWithoutVerification() { | 261 void FinishDefaultTestWithoutVerification() { |
| 262 output_.rv = callback_.WaitForResult(); | 262 output_.rv = callback_.WaitForResult(); |
| 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 (const SocketDataProvider* provider : data_vector_) { |
| 272 it != data_vector_.end(); ++it) { | 272 EXPECT_TRUE(provider->AllReadDataConsumed()); |
| 273 EXPECT_TRUE((*it)->at_read_eof()) << "Read count: " | 273 EXPECT_TRUE(provider->AllWriteDataConsumed()); |
| 274 << (*it)->read_count() | |
| 275 << " Read index: " | |
| 276 << (*it)->read_index(); | |
| 277 EXPECT_TRUE((*it)->at_write_eof()) << "Write count: " | |
| 278 << (*it)->write_count() | |
| 279 << " Write index: " | |
| 280 << (*it)->write_index(); | |
| 281 } | 274 } |
| 282 } | 275 } |
| 283 | 276 |
| 284 // Occasionally a test will expect to error out before certain reads are | 277 // 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 | 278 // processed. In that case we want to explicitly ensure that the reads were |
| 286 // not processed. | 279 // not processed. |
| 287 void VerifyDataNotConsumed() { | 280 void VerifyDataNotConsumed() { |
| 288 for (DataVector::iterator it = data_vector_.begin(); | 281 for (const SocketDataProvider* provider : data_vector_) { |
| 289 it != data_vector_.end(); ++it) { | 282 EXPECT_FALSE(provider->AllReadDataConsumed()); |
| 290 EXPECT_TRUE(!(*it)->at_read_eof()) << "Read count: " | 283 EXPECT_FALSE(provider->AllWriteDataConsumed()); |
| 291 << (*it)->read_count() | |
| 292 << " Read index: " | |
| 293 << (*it)->read_index(); | |
| 294 EXPECT_TRUE(!(*it)->at_write_eof()) << "Write count: " | |
| 295 << (*it)->write_count() | |
| 296 << " Write index: " | |
| 297 << (*it)->write_index(); | |
| 298 } | 284 } |
| 299 } | 285 } |
| 300 | 286 |
| 301 void RunToCompletion(SocketDataProvider* data) { | 287 void RunToCompletion(SocketDataProvider* data) { |
| 302 RunPreTestSetup(); | 288 RunPreTestSetup(); |
| 303 AddData(data); | 289 AddData(data); |
| 304 RunDefaultTest(); | 290 RunDefaultTest(); |
| 305 VerifyDataConsumed(); | 291 VerifyDataConsumed(); |
| 306 } | 292 } |
| 307 | 293 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 // the results into a single string. | 620 // the results into a single string. |
| 635 | 621 |
| 636 // Read the server push body. | 622 // Read the server push body. |
| 637 std::string result2; | 623 std::string result2; |
| 638 ReadResult(trans2.get(), data, &result2); | 624 ReadResult(trans2.get(), data, &result2); |
| 639 // Read the response body. | 625 // Read the response body. |
| 640 std::string result; | 626 std::string result; |
| 641 ReadResult(trans, data, &result); | 627 ReadResult(trans, data, &result); |
| 642 | 628 |
| 643 // Verify that we consumed all test data. | 629 // Verify that we consumed all test data. |
| 644 EXPECT_TRUE(data->at_read_eof()); | 630 EXPECT_TRUE(data->AllReadDataConsumed()); |
| 645 EXPECT_TRUE(data->at_write_eof()); | 631 EXPECT_TRUE(data->AllWriteDataConsumed()); |
| 646 | 632 |
| 647 // Verify that the received push data is same as the expected push data. | 633 // Verify that the received push data is same as the expected push data. |
| 648 EXPECT_EQ(result2.compare(expected), 0) << "Received data: " | 634 EXPECT_EQ(result2.compare(expected), 0) << "Received data: " |
| 649 << result2 | 635 << result2 |
| 650 << "||||| Expected data: " | 636 << "||||| Expected data: " |
| 651 << expected; | 637 << expected; |
| 652 | 638 |
| 653 // Verify the SYN_REPLY. | 639 // Verify the SYN_REPLY. |
| 654 // Copy the response info, because trans goes away. | 640 // Copy the response info, because trans goes away. |
| 655 *response = *trans->GetResponseInfo(); | 641 *response = *trans->GetResponseInfo(); |
| (...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2448 EXPECT_EQ(1, d.received_redirect_count()); | 2434 EXPECT_EQ(1, d.received_redirect_count()); |
| 2449 | 2435 |
| 2450 r->FollowDeferredRedirect(); | 2436 r->FollowDeferredRedirect(); |
| 2451 base::RunLoop().Run(); | 2437 base::RunLoop().Run(); |
| 2452 EXPECT_EQ(1, d.response_started_count()); | 2438 EXPECT_EQ(1, d.response_started_count()); |
| 2453 EXPECT_FALSE(d.received_data_before_response()); | 2439 EXPECT_FALSE(d.received_data_before_response()); |
| 2454 EXPECT_EQ(URLRequestStatus::SUCCESS, r->status().status()); | 2440 EXPECT_EQ(URLRequestStatus::SUCCESS, r->status().status()); |
| 2455 std::string contents("hello!"); | 2441 std::string contents("hello!"); |
| 2456 EXPECT_EQ(contents, d.data_received()); | 2442 EXPECT_EQ(contents, d.data_received()); |
| 2457 } | 2443 } |
| 2458 EXPECT_TRUE(data.at_read_eof()); | 2444 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2459 EXPECT_TRUE(data.at_write_eof()); | 2445 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2460 EXPECT_TRUE(data2.at_read_eof()); | 2446 EXPECT_TRUE(data2.AllReadDataConsumed()); |
| 2461 EXPECT_TRUE(data2.at_write_eof()); | 2447 EXPECT_TRUE(data2.AllWriteDataConsumed()); |
| 2462 } | 2448 } |
| 2463 | 2449 |
| 2464 // Send a spdy request to www.example.org. Get a pushed stream that redirects to | 2450 // Send a spdy request to www.example.org. Get a pushed stream that redirects to |
| 2465 // www.foo.com. | 2451 // www.foo.com. |
| 2466 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) { | 2452 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) { |
| 2467 scoped_ptr<SpdyHeaderBlock> headers( | 2453 scoped_ptr<SpdyHeaderBlock> headers( |
| 2468 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); | 2454 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); |
| 2469 (*headers)["user-agent"] = ""; | 2455 (*headers)["user-agent"] = ""; |
| 2470 (*headers)["accept-encoding"] = "gzip, deflate"; | 2456 (*headers)["accept-encoding"] = "gzip, deflate"; |
| 2471 | 2457 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 EXPECT_EQ(1, d2.received_redirect_count()); | 2526 EXPECT_EQ(1, d2.received_redirect_count()); |
| 2541 | 2527 |
| 2542 r2->FollowDeferredRedirect(); | 2528 r2->FollowDeferredRedirect(); |
| 2543 base::RunLoop().Run(); | 2529 base::RunLoop().Run(); |
| 2544 EXPECT_EQ(1, d2.response_started_count()); | 2530 EXPECT_EQ(1, d2.response_started_count()); |
| 2545 EXPECT_FALSE(d2.received_data_before_response()); | 2531 EXPECT_FALSE(d2.received_data_before_response()); |
| 2546 EXPECT_EQ(URLRequestStatus::SUCCESS, r2->status().status()); | 2532 EXPECT_EQ(URLRequestStatus::SUCCESS, r2->status().status()); |
| 2547 std::string contents2("hello!"); | 2533 std::string contents2("hello!"); |
| 2548 EXPECT_EQ(contents2, d2.data_received()); | 2534 EXPECT_EQ(contents2, d2.data_received()); |
| 2549 } | 2535 } |
| 2550 data.CompleteRead(); | 2536 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2551 data2.CompleteRead(); | 2537 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2552 EXPECT_TRUE(data.at_read_eof()); | 2538 EXPECT_TRUE(data2.AllReadDataConsumed()); |
| 2553 EXPECT_TRUE(data.at_write_eof()); | 2539 EXPECT_TRUE(data2.AllWriteDataConsumed()); |
| 2554 EXPECT_TRUE(data2.at_read_eof()); | |
| 2555 EXPECT_TRUE(data2.at_write_eof()); | |
| 2556 } | 2540 } |
| 2557 | 2541 |
| 2558 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { | 2542 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { |
| 2559 scoped_ptr<SpdyFrame> stream1_syn( | 2543 scoped_ptr<SpdyFrame> stream1_syn( |
| 2560 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2544 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 2561 scoped_ptr<SpdyFrame> stream1_body( | 2545 scoped_ptr<SpdyFrame> stream1_body( |
| 2562 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2546 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 2563 MockWrite writes[] = { | 2547 MockWrite writes[] = { |
| 2564 CreateMockWrite(*stream1_syn, 0), | 2548 CreateMockWrite(*stream1_syn, 0), |
| 2565 }; | 2549 }; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2718 | 2702 |
| 2719 // Start the transaction with basic parameters. | 2703 // Start the transaction with basic parameters. |
| 2720 TestCompletionCallback callback; | 2704 TestCompletionCallback callback; |
| 2721 int rv = trans->Start( | 2705 int rv = trans->Start( |
| 2722 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2706 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 2723 EXPECT_EQ(ERR_IO_PENDING, rv); | 2707 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2724 rv = callback.WaitForResult(); | 2708 rv = callback.WaitForResult(); |
| 2725 EXPECT_EQ(OK, rv); | 2709 EXPECT_EQ(OK, rv); |
| 2726 | 2710 |
| 2727 // Verify that we consumed all test data. | 2711 // Verify that we consumed all test data. |
| 2728 EXPECT_TRUE(data.at_read_eof()) << "Read count: " | 2712 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2729 << data.read_count() | 2713 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2730 << " Read index: " | |
| 2731 << data.read_index(); | |
| 2732 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | |
| 2733 << data.write_count() | |
| 2734 << " Write index: " | |
| 2735 << data.write_index(); | |
| 2736 | 2714 |
| 2737 // Verify the SYN_REPLY. | 2715 // Verify the SYN_REPLY. |
| 2738 HttpResponseInfo response = *trans->GetResponseInfo(); | 2716 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 2739 EXPECT_TRUE(response.headers.get() != NULL); | 2717 EXPECT_TRUE(response.headers.get() != NULL); |
| 2740 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2718 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 2741 } | 2719 } |
| 2742 | 2720 |
| 2743 // Verify that we don't leak streams and that we properly send a reset | 2721 // Verify that we don't leak streams and that we properly send a reset |
| 2744 // if the server pushes the same stream twice. | 2722 // if the server pushes the same stream twice. |
| 2745 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) { | 2723 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2936 | 2914 |
| 2937 // Start the transaction with basic parameters. | 2915 // Start the transaction with basic parameters. |
| 2938 TestCompletionCallback callback; | 2916 TestCompletionCallback callback; |
| 2939 int rv = trans->Start( | 2917 int rv = trans->Start( |
| 2940 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2918 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 2941 EXPECT_EQ(ERR_IO_PENDING, rv); | 2919 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2942 rv = callback.WaitForResult(); | 2920 rv = callback.WaitForResult(); |
| 2943 EXPECT_EQ(OK, rv); | 2921 EXPECT_EQ(OK, rv); |
| 2944 | 2922 |
| 2945 // Verify that we consumed all test data. | 2923 // Verify that we consumed all test data. |
| 2946 EXPECT_TRUE(data.at_read_eof()) << "Read count: " | 2924 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2947 << data.read_count() | 2925 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2948 << " Read index: " | |
| 2949 << data.read_index(); | |
| 2950 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | |
| 2951 << data.write_count() | |
| 2952 << " Write index: " | |
| 2953 << data.write_index(); | |
| 2954 | 2926 |
| 2955 // Verify the SYN_REPLY. | 2927 // Verify the SYN_REPLY. |
| 2956 HttpResponseInfo response = *trans->GetResponseInfo(); | 2928 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 2957 EXPECT_TRUE(response.headers.get() != NULL); | 2929 EXPECT_TRUE(response.headers.get() != NULL); |
| 2958 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2930 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 2959 } | 2931 } |
| 2960 | 2932 |
| 2961 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { | 2933 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { |
| 2962 scoped_ptr<SpdyFrame> stream1_syn( | 2934 scoped_ptr<SpdyFrame> stream1_syn( |
| 2963 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2935 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2991 | 2963 |
| 2992 // Start the transaction with basic parameters. | 2964 // Start the transaction with basic parameters. |
| 2993 TestCompletionCallback callback; | 2965 TestCompletionCallback callback; |
| 2994 int rv = trans->Start( | 2966 int rv = trans->Start( |
| 2995 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2967 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 2996 EXPECT_EQ(ERR_IO_PENDING, rv); | 2968 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2997 rv = callback.WaitForResult(); | 2969 rv = callback.WaitForResult(); |
| 2998 EXPECT_EQ(OK, rv); | 2970 EXPECT_EQ(OK, rv); |
| 2999 | 2971 |
| 3000 // Verify that we consumed all test data. | 2972 // Verify that we consumed all test data. |
| 3001 EXPECT_TRUE(data.at_read_eof()) << "Read count: " | 2973 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 3002 << data.read_count() | 2974 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 3003 << " Read index: " | |
| 3004 << data.read_index(); | |
| 3005 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | |
| 3006 << data.write_count() | |
| 3007 << " Write index: " | |
| 3008 << data.write_index(); | |
| 3009 | 2975 |
| 3010 // Verify the SYN_REPLY. | 2976 // Verify the SYN_REPLY. |
| 3011 HttpResponseInfo response = *trans->GetResponseInfo(); | 2977 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3012 EXPECT_TRUE(response.headers.get() != NULL); | 2978 EXPECT_TRUE(response.headers.get() != NULL); |
| 3013 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2979 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3014 } | 2980 } |
| 3015 | 2981 |
| 3016 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) { | 2982 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) { |
| 3017 scoped_ptr<SpdyFrame> stream1_syn( | 2983 scoped_ptr<SpdyFrame> stream1_syn( |
| 3018 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2984 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3050 | 3016 |
| 3051 // Start the transaction with basic parameters. | 3017 // Start the transaction with basic parameters. |
| 3052 TestCompletionCallback callback; | 3018 TestCompletionCallback callback; |
| 3053 int rv = trans->Start( | 3019 int rv = trans->Start( |
| 3054 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3020 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 3055 EXPECT_EQ(ERR_IO_PENDING, rv); | 3021 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3056 rv = callback.WaitForResult(); | 3022 rv = callback.WaitForResult(); |
| 3057 EXPECT_EQ(OK, rv); | 3023 EXPECT_EQ(OK, rv); |
| 3058 | 3024 |
| 3059 // Verify that we consumed all test data. | 3025 // Verify that we consumed all test data. |
| 3060 EXPECT_TRUE(data.at_read_eof()) << "Read count: " | 3026 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 3061 << data.read_count() | 3027 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 3062 << " Read index: " | |
| 3063 << data.read_index(); | |
| 3064 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | |
| 3065 << data.write_count() | |
| 3066 << " Write index: " | |
| 3067 << data.write_index(); | |
| 3068 | 3028 |
| 3069 // Verify the SYN_REPLY. | 3029 // Verify the SYN_REPLY. |
| 3070 HttpResponseInfo response = *trans->GetResponseInfo(); | 3030 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3071 EXPECT_TRUE(response.headers.get() != NULL); | 3031 EXPECT_TRUE(response.headers.get() != NULL); |
| 3072 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3032 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3073 } | 3033 } |
| 3074 | 3034 |
| 3075 // Verify that various SynReply headers parse correctly through the | 3035 // Verify that various SynReply headers parse correctly through the |
| 3076 // HTTP layer. | 3036 // HTTP layer. |
| 3077 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { | 3037 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3522 writes, arraysize(writes)); | 3482 writes, arraysize(writes)); |
| 3523 | 3483 |
| 3524 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3484 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3525 BoundNetLog(), GetParam(), NULL); | 3485 BoundNetLog(), GetParam(), NULL); |
| 3526 helper.SetDeterministic(); | 3486 helper.SetDeterministic(); |
| 3527 helper.RunPreTestSetup(); | 3487 helper.RunPreTestSetup(); |
| 3528 helper.AddDeterministicData(&data); | 3488 helper.AddDeterministicData(&data); |
| 3529 EXPECT_TRUE(helper.StartDefaultTest()); | 3489 EXPECT_TRUE(helper.StartDefaultTest()); |
| 3530 data.RunFor(2); | 3490 data.RunFor(2); |
| 3531 helper.FinishDefaultTest(); | 3491 helper.FinishDefaultTest(); |
| 3532 EXPECT_TRUE(data.at_write_eof()); | 3492 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 3533 EXPECT_TRUE(!data.at_read_eof()); | 3493 EXPECT_TRUE(!data.AllReadDataConsumed()); |
| 3534 TransactionHelperResult out = helper.output(); | 3494 TransactionHelperResult out = helper.output(); |
| 3535 EXPECT_EQ(ERR_FAILED, out.rv); | 3495 EXPECT_EQ(ERR_FAILED, out.rv); |
| 3536 } | 3496 } |
| 3537 | 3497 |
| 3538 // Test that partial writes work. | 3498 // Test that partial writes work. |
| 3539 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { | 3499 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { |
| 3540 // Chop the SYN_STREAM frame into 5 chunks. | 3500 // Chop the SYN_STREAM frame into 5 chunks. |
| 3541 scoped_ptr<SpdyFrame> req( | 3501 scoped_ptr<SpdyFrame> req( |
| 3542 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3502 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3543 const int kChunks = 5; | 3503 const int kChunks = 5; |
| (...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5220 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5180 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5221 | 5181 |
| 5222 // Verify the pushed stream. | 5182 // Verify the pushed stream. |
| 5223 EXPECT_TRUE(response2.headers.get() != NULL); | 5183 EXPECT_TRUE(response2.headers.get() != NULL); |
| 5224 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5184 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 5225 | 5185 |
| 5226 // Read the final EOF (which will close the session) | 5186 // Read the final EOF (which will close the session) |
| 5227 data.RunFor(1); | 5187 data.RunFor(1); |
| 5228 | 5188 |
| 5229 // Verify that we consumed all test data. | 5189 // Verify that we consumed all test data. |
| 5230 EXPECT_TRUE(data.at_read_eof()); | 5190 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 5231 EXPECT_TRUE(data.at_write_eof()); | 5191 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 5232 } | 5192 } |
| 5233 | 5193 |
| 5234 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames | 5194 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames |
| 5235 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { | 5195 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { |
| 5236 // We push a stream and attempt to claim it before the headers come down. | 5196 // We push a stream and attempt to claim it before the headers come down. |
| 5237 scoped_ptr<SpdyFrame> stream1_syn( | 5197 scoped_ptr<SpdyFrame> stream1_syn( |
| 5238 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5198 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5239 scoped_ptr<SpdyFrame> stream1_body( | 5199 scoped_ptr<SpdyFrame> stream1_body( |
| 5240 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5200 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5241 MockWrite writes[] = { | 5201 MockWrite writes[] = { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5360 // Verify we got all the headers from all header blocks. | 5320 // Verify we got all the headers from all header blocks. |
| 5361 if (spdy_util_.spdy_version() < SPDY4) | 5321 if (spdy_util_.spdy_version() < SPDY4) |
| 5362 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta")); | 5322 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta")); |
| 5363 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); | 5323 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); |
| 5364 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); | 5324 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); |
| 5365 | 5325 |
| 5366 // Read the final EOF (which will close the session) | 5326 // Read the final EOF (which will close the session) |
| 5367 data.RunFor(1); | 5327 data.RunFor(1); |
| 5368 | 5328 |
| 5369 // Verify that we consumed all test data. | 5329 // Verify that we consumed all test data. |
| 5370 EXPECT_TRUE(data.at_read_eof()); | 5330 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 5371 EXPECT_TRUE(data.at_write_eof()); | 5331 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 5372 } | 5332 } |
| 5373 | 5333 |
| 5374 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { | 5334 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { |
| 5375 // We push a stream and attempt to claim it before the headers come down. | 5335 // We push a stream and attempt to claim it before the headers come down. |
| 5376 scoped_ptr<SpdyFrame> stream1_syn( | 5336 scoped_ptr<SpdyFrame> stream1_syn( |
| 5377 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5337 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5378 scoped_ptr<SpdyFrame> stream1_body( | 5338 scoped_ptr<SpdyFrame> stream1_body( |
| 5379 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5339 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5380 MockWrite writes[] = { | 5340 MockWrite writes[] = { |
| 5381 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5341 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5467 VerifyStreamsClosed(helper); | 5427 VerifyStreamsClosed(helper); |
| 5468 | 5428 |
| 5469 // Verify the SYN_REPLY. | 5429 // Verify the SYN_REPLY. |
| 5470 EXPECT_TRUE(response.headers.get() != NULL); | 5430 EXPECT_TRUE(response.headers.get() != NULL); |
| 5471 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5431 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5472 | 5432 |
| 5473 // Read the final EOF (which will close the session). | 5433 // Read the final EOF (which will close the session). |
| 5474 data.RunFor(1); | 5434 data.RunFor(1); |
| 5475 | 5435 |
| 5476 // Verify that we consumed all test data. | 5436 // Verify that we consumed all test data. |
| 5477 EXPECT_TRUE(data.at_read_eof()); | 5437 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 5478 EXPECT_TRUE(data.at_write_eof()); | 5438 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 5479 } | 5439 } |
| 5480 | 5440 |
| 5481 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { | 5441 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { |
| 5482 scoped_ptr<SpdyFrame> req( | 5442 scoped_ptr<SpdyFrame> req( |
| 5483 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5443 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5484 scoped_ptr<SpdyFrame> rst( | 5444 scoped_ptr<SpdyFrame> rst( |
| 5485 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 5445 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 5486 MockWrite writes[] = { | 5446 MockWrite writes[] = { |
| 5487 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4), | 5447 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4), |
| 5488 }; | 5448 }; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5653 | 5613 |
| 5654 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5614 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5655 EXPECT_EQ(ERR_IO_PENDING, rv); | 5615 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5656 rv = callback.WaitForResult(); | 5616 rv = callback.WaitForResult(); |
| 5657 | 5617 |
| 5658 // Read the response body. | 5618 // Read the response body. |
| 5659 std::string result; | 5619 std::string result; |
| 5660 ReadResult(trans, &data, &result); | 5620 ReadResult(trans, &data, &result); |
| 5661 | 5621 |
| 5662 // Verify that we consumed all test data. | 5622 // Verify that we consumed all test data. |
| 5663 EXPECT_TRUE(data.at_read_eof()); | 5623 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 5664 EXPECT_TRUE(data.at_write_eof()); | 5624 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 5665 | 5625 |
| 5666 // Verify the SYN_REPLY. | 5626 // Verify the SYN_REPLY. |
| 5667 // Copy the response info, because trans goes away. | 5627 // Copy the response info, because trans goes away. |
| 5668 response = *trans->GetResponseInfo(); | 5628 response = *trans->GetResponseInfo(); |
| 5669 | 5629 |
| 5670 VerifyStreamsClosed(helper); | 5630 VerifyStreamsClosed(helper); |
| 5671 | 5631 |
| 5672 // Verify the SYN_REPLY. | 5632 // Verify the SYN_REPLY. |
| 5673 EXPECT_TRUE(response.headers.get() != NULL); | 5633 EXPECT_TRUE(response.headers.get() != NULL); |
| 5674 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5634 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5707 | 5667 |
| 5708 // Start the transaction with basic parameters. | 5668 // Start the transaction with basic parameters. |
| 5709 TestCompletionCallback callback; | 5669 TestCompletionCallback callback; |
| 5710 int rv = trans->Start( | 5670 int rv = trans->Start( |
| 5711 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5671 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 5712 EXPECT_EQ(ERR_IO_PENDING, rv); | 5672 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5713 rv = callback.WaitForResult(); | 5673 rv = callback.WaitForResult(); |
| 5714 EXPECT_EQ(OK, rv); | 5674 EXPECT_EQ(OK, rv); |
| 5715 | 5675 |
| 5716 // Verify that we consumed all test data. | 5676 // Verify that we consumed all test data. |
| 5717 EXPECT_TRUE(data.at_read_eof()) << "Read count: " | 5677 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 5718 << data.read_count() | 5678 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 5719 << " Read index: " | |
| 5720 << data.read_index(); | |
| 5721 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | |
| 5722 << data.write_count() | |
| 5723 << " Write index: " | |
| 5724 << data.write_index(); | |
| 5725 | 5679 |
| 5726 // Verify the SYN_REPLY. | 5680 // Verify the SYN_REPLY. |
| 5727 HttpResponseInfo response = *trans->GetResponseInfo(); | 5681 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 5728 EXPECT_TRUE(response.headers.get() != NULL); | 5682 EXPECT_TRUE(response.headers.get() != NULL); |
| 5729 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5683 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5730 } | 5684 } |
| 5731 | 5685 |
| 5732 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { | 5686 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { |
| 5733 // This first request will start to establish the SpdySession. | 5687 // This first request will start to establish the SpdySession. |
| 5734 // Then we will start the second (MEDIUM priority) and then third | 5688 // Then we will start the second (MEDIUM priority) and then third |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6647 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6601 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
| 6648 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6602 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
| 6649 new SSLSocketDataProvider(ASYNC, OK)); | 6603 new SSLSocketDataProvider(ASYNC, OK)); |
| 6650 // Set to TLS_RSA_WITH_NULL_MD5 | 6604 // Set to TLS_RSA_WITH_NULL_MD5 |
| 6651 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6605 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
| 6652 | 6606 |
| 6653 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6607 RunTLSUsageCheckTest(ssl_provider.Pass()); |
| 6654 } | 6608 } |
| 6655 | 6609 |
| 6656 } // namespace net | 6610 } // namespace net |
| OLD | NEW |