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/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 DATA_FLAG_NONE // Data Flags | 1692 DATA_FLAG_NONE // Data Flags |
1693 }; | 1693 }; |
1694 scoped_ptr<SpdyHeaderBlock> put_headers( | 1694 scoped_ptr<SpdyHeaderBlock> put_headers( |
1695 spdy_util_.ConstructPutHeaderBlock("http://www.google.com", 0)); | 1695 spdy_util_.ConstructPutHeaderBlock("http://www.google.com", 0)); |
1696 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( | 1696 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( |
1697 kSynStartHeader, put_headers.Pass())); | 1697 kSynStartHeader, put_headers.Pass())); |
1698 MockWrite writes[] = { | 1698 MockWrite writes[] = { |
1699 CreateMockWrite(*req), | 1699 CreateMockWrite(*req), |
1700 }; | 1700 }; |
1701 | 1701 |
| 1702 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
1702 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1703 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
1703 const SpdyHeaderInfo kSynReplyHeader = { | |
1704 SYN_REPLY, // Kind = SynReply | |
1705 1, // Stream ID | |
1706 0, // Associated stream ID | |
1707 ConvertRequestPriorityToSpdyPriority( | |
1708 LOWEST, spdy_util_.spdy_version()), | |
1709 kSpdyCredentialSlotUnused, | |
1710 CONTROL_FLAG_NONE, // Control Flags | |
1711 false, // Compressed | |
1712 RST_STREAM_INVALID, // Status | |
1713 NULL, // Data | |
1714 0, // Length | |
1715 DATA_FLAG_NONE // Data Flags | |
1716 }; | |
1717 scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); | |
1718 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; | |
1719 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | |
1720 (*reply_headers)["content-length"] = "1234"; | |
1721 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyFrame( | |
1722 kSynReplyHeader, reply_headers.Pass())); | |
1723 MockRead reads[] = { | 1704 MockRead reads[] = { |
1724 CreateMockRead(*resp), | 1705 CreateMockRead(*resp), |
1725 CreateMockRead(*body), | 1706 CreateMockRead(*body), |
1726 MockRead(ASYNC, 0, 0) // EOF | 1707 MockRead(ASYNC, 0, 0) // EOF |
1727 }; | 1708 }; |
1728 | 1709 |
1729 DelayedSocketData data(1, reads, arraysize(reads), | 1710 DelayedSocketData data(1, reads, arraysize(reads), |
1730 writes, arraysize(writes)); | 1711 writes, arraysize(writes)); |
1731 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 1712 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
1732 BoundNetLog(), GetParam(), NULL); | 1713 BoundNetLog(), GetParam(), NULL); |
(...skipping 26 matching lines...) Expand all Loading... |
1759 DATA_FLAG_NONE // Data Flags | 1740 DATA_FLAG_NONE // Data Flags |
1760 }; | 1741 }; |
1761 scoped_ptr<SpdyHeaderBlock> head_headers( | 1742 scoped_ptr<SpdyHeaderBlock> head_headers( |
1762 spdy_util_.ConstructHeadHeaderBlock("http://www.google.com", 0)); | 1743 spdy_util_.ConstructHeadHeaderBlock("http://www.google.com", 0)); |
1763 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( | 1744 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( |
1764 kSynStartHeader, head_headers.Pass())); | 1745 kSynStartHeader, head_headers.Pass())); |
1765 MockWrite writes[] = { | 1746 MockWrite writes[] = { |
1766 CreateMockWrite(*req), | 1747 CreateMockWrite(*req), |
1767 }; | 1748 }; |
1768 | 1749 |
| 1750 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
1769 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1751 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
1770 const SpdyHeaderInfo kSynReplyHeader = { | |
1771 SYN_REPLY, // Kind = SynReply | |
1772 1, // Stream ID | |
1773 0, // Associated stream ID | |
1774 ConvertRequestPriorityToSpdyPriority( | |
1775 LOWEST, spdy_util_.spdy_version()), | |
1776 kSpdyCredentialSlotUnused, | |
1777 CONTROL_FLAG_NONE, // Control Flags | |
1778 false, // Compressed | |
1779 RST_STREAM_INVALID, // Status | |
1780 NULL, // Data | |
1781 0, // Length | |
1782 DATA_FLAG_NONE // Data Flags | |
1783 }; | |
1784 scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); | |
1785 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; | |
1786 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | |
1787 (*reply_headers)["content-length"] = "1234"; | |
1788 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyFrame( | |
1789 kSynReplyHeader, | |
1790 reply_headers.Pass())); | |
1791 MockRead reads[] = { | 1752 MockRead reads[] = { |
1792 CreateMockRead(*resp), | 1753 CreateMockRead(*resp), |
1793 CreateMockRead(*body), | 1754 CreateMockRead(*body), |
1794 MockRead(ASYNC, 0, 0) // EOF | 1755 MockRead(ASYNC, 0, 0) // EOF |
1795 }; | 1756 }; |
1796 | 1757 |
1797 DelayedSocketData data(1, reads, arraysize(reads), | 1758 DelayedSocketData data(1, reads, arraysize(reads), |
1798 writes, arraysize(writes)); | 1759 writes, arraysize(writes)); |
1799 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 1760 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
1800 BoundNetLog(), GetParam(), NULL); | 1761 BoundNetLog(), GetParam(), NULL); |
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3364 header_block[name] += value; | 3325 header_block[name] += value; |
3365 } | 3326 } |
3366 } | 3327 } |
3367 EXPECT_EQ(test_cases[i].expected_headers, header_block); | 3328 EXPECT_EQ(test_cases[i].expected_headers, header_block); |
3368 } | 3329 } |
3369 } | 3330 } |
3370 | 3331 |
3371 // Verify that various SynReply headers parse vary fields correctly | 3332 // Verify that various SynReply headers parse vary fields correctly |
3372 // through the HTTP layer, and the response matches the request. | 3333 // through the HTTP layer, and the response matches the request. |
3373 TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { | 3334 TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
3374 static const SpdyHeaderInfo syn_reply_info = { | |
3375 SYN_REPLY, // Syn Reply | |
3376 1, // Stream ID | |
3377 0, // Associated Stream ID | |
3378 ConvertRequestPriorityToSpdyPriority( | |
3379 LOWEST, spdy_util_.spdy_version()), | |
3380 kSpdyCredentialSlotUnused, | |
3381 CONTROL_FLAG_NONE, // Control Flags | |
3382 false, // Compressed | |
3383 RST_STREAM_INVALID, // Status | |
3384 NULL, // Data | |
3385 0, // Data Length | |
3386 DATA_FLAG_NONE // Data Flags | |
3387 }; | |
3388 // Modify the following data to change/add test cases: | 3335 // Modify the following data to change/add test cases: |
3389 struct SynReplyTests { | 3336 struct SynReplyTests { |
3390 const SpdyHeaderInfo* syn_reply; | |
3391 bool vary_matches; | 3337 bool vary_matches; |
3392 int num_headers[2]; | 3338 int num_headers[2]; |
3393 const char* extra_headers[2][16]; | 3339 const char* extra_headers[2][16]; |
3394 } test_cases[] = { | 3340 } test_cases[] = { |
3395 // Test the case of a multi-valued cookie. When the value is delimited | 3341 // Test the case of a multi-valued cookie. When the value is delimited |
3396 // with NUL characters, it needs to be unfolded into multiple headers. | 3342 // with NUL characters, it needs to be unfolded into multiple headers. |
3397 { | 3343 { |
3398 &syn_reply_info, | |
3399 true, | 3344 true, |
3400 { 1, 4 }, | 3345 { 1, 4 }, |
3401 { { "cookie", "val1,val2", | 3346 { { "cookie", "val1,val2", |
3402 NULL | 3347 NULL |
3403 }, | 3348 }, |
3404 { "vary", "cookie", | 3349 { "vary", "cookie", |
3405 spdy_util_.GetStatusKey(), "200", | 3350 spdy_util_.GetStatusKey(), "200", |
3406 spdy_util_.GetPathKey(), "/index.php", | 3351 spdy_util_.GetPathKey(), "/index.php", |
3407 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3352 spdy_util_.GetVersionKey(), "HTTP/1.1", |
3408 NULL | 3353 NULL |
3409 } | 3354 } |
3410 } | 3355 } |
3411 }, { // Multiple vary fields. | 3356 }, { // Multiple vary fields. |
3412 &syn_reply_info, | |
3413 true, | 3357 true, |
3414 { 2, 5 }, | 3358 { 2, 5 }, |
3415 { { "friend", "barney", | 3359 { { "friend", "barney", |
3416 "enemy", "snaggletooth", | 3360 "enemy", "snaggletooth", |
3417 NULL | 3361 NULL |
3418 }, | 3362 }, |
3419 { "vary", "friend", | 3363 { "vary", "friend", |
3420 "vary", "enemy", | 3364 "vary", "enemy", |
3421 spdy_util_.GetStatusKey(), "200", | 3365 spdy_util_.GetStatusKey(), "200", |
3422 spdy_util_.GetPathKey(), "/index.php", | 3366 spdy_util_.GetPathKey(), "/index.php", |
3423 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3367 spdy_util_.GetVersionKey(), "HTTP/1.1", |
3424 NULL | 3368 NULL |
3425 } | 3369 } |
3426 } | 3370 } |
3427 }, { // Test a '*' vary field. | 3371 }, { // Test a '*' vary field. |
3428 &syn_reply_info, | |
3429 false, | 3372 false, |
3430 { 1, 4 }, | 3373 { 1, 4 }, |
3431 { { "cookie", "val1,val2", | 3374 { { "cookie", "val1,val2", |
3432 NULL | 3375 NULL |
3433 }, | 3376 }, |
3434 { "vary", "*", | 3377 { "vary", "*", |
3435 spdy_util_.GetStatusKey(), "200", | 3378 spdy_util_.GetStatusKey(), "200", |
3436 spdy_util_.GetPathKey(), "/index.php", | 3379 spdy_util_.GetPathKey(), "/index.php", |
3437 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3380 spdy_util_.GetVersionKey(), "HTTP/1.1", |
3438 NULL | 3381 NULL |
3439 } | 3382 } |
3440 } | 3383 } |
3441 }, { // Multiple comma-separated vary fields. | 3384 }, { // Multiple comma-separated vary fields. |
3442 &syn_reply_info, | |
3443 true, | 3385 true, |
3444 { 2, 4 }, | 3386 { 2, 4 }, |
3445 { { "friend", "barney", | 3387 { { "friend", "barney", |
3446 "enemy", "snaggletooth", | 3388 "enemy", "snaggletooth", |
3447 NULL | 3389 NULL |
3448 }, | 3390 }, |
3449 { "vary", "friend,enemy", | 3391 { "vary", "friend,enemy", |
3450 spdy_util_.GetStatusKey(), "200", | 3392 spdy_util_.GetStatusKey(), "200", |
3451 spdy_util_.GetPathKey(), "/index.php", | 3393 spdy_util_.GetPathKey(), "/index.php", |
3452 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3394 spdy_util_.GetVersionKey(), "HTTP/1.1", |
3453 NULL | 3395 NULL |
3454 } | 3396 } |
3455 } | 3397 } |
3456 } | 3398 } |
3457 }; | 3399 }; |
3458 | 3400 |
3459 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 3401 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
3460 // Construct the request. | 3402 // Construct the request. |
3461 scoped_ptr<SpdyFrame> frame_req( | 3403 scoped_ptr<SpdyFrame> frame_req( |
3462 spdy_util_.ConstructSpdyGet(test_cases[i].extra_headers[0], | 3404 spdy_util_.ConstructSpdyGet(test_cases[i].extra_headers[0], |
3463 test_cases[i].num_headers[0], | 3405 test_cases[i].num_headers[0], |
3464 false, 1, LOWEST, true)); | 3406 false, 1, LOWEST, true)); |
3465 | 3407 |
3466 MockWrite writes[] = { | 3408 MockWrite writes[] = { |
3467 CreateMockWrite(*frame_req), | 3409 CreateMockWrite(*frame_req), |
3468 }; | 3410 }; |
3469 | 3411 |
3470 // Construct the reply. | 3412 // Construct the reply. |
| 3413 SpdyHeaderBlock reply_headers; |
| 3414 AppendToHeaderBlock(test_cases[i].extra_headers[1], |
| 3415 test_cases[i].num_headers[1], |
| 3416 &reply_headers); |
3471 scoped_ptr<SpdyFrame> frame_reply( | 3417 scoped_ptr<SpdyFrame> frame_reply( |
3472 spdy_util_.ConstructSpdyFrame(*test_cases[i].syn_reply, | 3418 spdy_util_.ConstructSpdyReply(1, reply_headers)); |
3473 test_cases[i].extra_headers[1], | |
3474 test_cases[i].num_headers[1], | |
3475 NULL, | |
3476 0)); | |
3477 | 3419 |
3478 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3420 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
3479 MockRead reads[] = { | 3421 MockRead reads[] = { |
3480 CreateMockRead(*frame_reply), | 3422 CreateMockRead(*frame_reply), |
3481 CreateMockRead(*body), | 3423 CreateMockRead(*body), |
3482 MockRead(ASYNC, 0, 0) // EOF | 3424 MockRead(ASYNC, 0, 0) // EOF |
3483 }; | 3425 }; |
3484 | 3426 |
3485 // Attach the headers to the request. | 3427 // Attach the headers to the request. |
3486 int header_count = test_cases[i].num_headers[0]; | 3428 int header_count = test_cases[i].num_headers[0]; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3521 void* iter = NULL; | 3463 void* iter = NULL; |
3522 std::string name, value, lines; | 3464 std::string name, value, lines; |
3523 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { | 3465 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { |
3524 lines.append(name); | 3466 lines.append(name); |
3525 lines.append(": "); | 3467 lines.append(": "); |
3526 lines.append(value); | 3468 lines.append(value); |
3527 lines.append("\n"); | 3469 lines.append("\n"); |
3528 } | 3470 } |
3529 | 3471 |
3530 // Construct the expected header reply string. | 3472 // Construct the expected header reply string. |
3531 SpdyHeaderBlock reply_headers; | |
3532 AppendToHeaderBlock(test_cases[i].extra_headers[1], | |
3533 test_cases[i].num_headers[1], | |
3534 &reply_headers); | |
3535 std::string expected_reply = | 3473 std::string expected_reply = |
3536 spdy_util_.ConstructSpdyReplyString(reply_headers); | 3474 spdy_util_.ConstructSpdyReplyString(reply_headers); |
3537 EXPECT_EQ(expected_reply, lines) << i; | 3475 EXPECT_EQ(expected_reply, lines) << i; |
3538 } | 3476 } |
3539 } | 3477 } |
3540 | 3478 |
3541 // Verify that we don't crash on invalid SynReply responses. | 3479 // Verify that we don't crash on invalid SynReply responses. |
3542 TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { | 3480 TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { |
3543 const SpdyHeaderInfo kSynStartHeader = { | |
3544 SYN_REPLY, // Kind = SynReply | |
3545 1, // Stream ID | |
3546 0, // Associated stream ID | |
3547 ConvertRequestPriorityToSpdyPriority( | |
3548 LOWEST, spdy_util_.spdy_version()), | |
3549 kSpdyCredentialSlotUnused, | |
3550 CONTROL_FLAG_NONE, // Control Flags | |
3551 false, // Compressed | |
3552 RST_STREAM_INVALID, // Status | |
3553 NULL, // Data | |
3554 0, // Length | |
3555 DATA_FLAG_NONE // Data Flags | |
3556 }; | |
3557 | |
3558 struct InvalidSynReplyTests { | 3481 struct InvalidSynReplyTests { |
3559 int num_headers; | 3482 int num_headers; |
3560 const char* headers[10]; | 3483 const char* headers[10]; |
3561 } test_cases[] = { | 3484 } test_cases[] = { |
3562 // SYN_REPLY missing status header | 3485 // SYN_REPLY missing status header |
3563 { 4, | 3486 { 4, |
3564 { "cookie", "val1", | 3487 { "cookie", "val1", |
3565 "cookie", "val2", | 3488 "cookie", "val2", |
3566 spdy_util_.GetPathKey(), "/index.php", | 3489 spdy_util_.GetPathKey(), "/index.php", |
3567 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3490 spdy_util_.GetVersionKey(), "HTTP/1.1", |
(...skipping 14 matching lines...) Expand all Loading... |
3582 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 3505 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
3583 scoped_ptr<SpdyFrame> req( | 3506 scoped_ptr<SpdyFrame> req( |
3584 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3507 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3585 scoped_ptr<SpdyFrame> rst( | 3508 scoped_ptr<SpdyFrame> rst( |
3586 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 3509 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
3587 MockWrite writes[] = { | 3510 MockWrite writes[] = { |
3588 CreateMockWrite(*req), | 3511 CreateMockWrite(*req), |
3589 CreateMockWrite(*rst), | 3512 CreateMockWrite(*rst), |
3590 }; | 3513 }; |
3591 | 3514 |
3592 scoped_ptr<SpdyFrame> resp( | 3515 // Construct the reply. |
3593 spdy_util_.ConstructSpdyFrame(kSynStartHeader, | 3516 SpdyHeaderBlock reply_headers; |
3594 NULL, 0, | 3517 AppendToHeaderBlock( |
3595 test_cases[i].headers, | 3518 test_cases[i].headers, test_cases[i].num_headers, &reply_headers); |
3596 test_cases[i].num_headers)); | 3519 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyReply(1, reply_headers)); |
3597 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | |
3598 MockRead reads[] = { | 3520 MockRead reads[] = { |
3599 CreateMockRead(*resp), | 3521 CreateMockRead(*resp), |
3600 MockRead(ASYNC, 0, 0) // EOF | 3522 MockRead(ASYNC, 0, 0) // EOF |
3601 }; | 3523 }; |
3602 | 3524 |
3603 DelayedSocketData data(1, reads, arraysize(reads), | 3525 DelayedSocketData data(1, reads, arraysize(reads), |
3604 writes, arraysize(writes)); | 3526 writes, arraysize(writes)); |
3605 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3527 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3606 BoundNetLog(), GetParam(), NULL); | 3528 BoundNetLog(), GetParam(), NULL); |
3607 helper.RunToCompletion(&data); | 3529 helper.RunToCompletion(&data); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4124 | 4046 |
4125 // Verify the case where we buffer data but read it after it has been buffered. | 4047 // Verify the case where we buffer data but read it after it has been buffered. |
4126 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { | 4048 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { |
4127 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4049 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
4128 | 4050 |
4129 scoped_ptr<SpdyFrame> req( | 4051 scoped_ptr<SpdyFrame> req( |
4130 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4052 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
4131 MockWrite writes[] = { CreateMockWrite(*req) }; | 4053 MockWrite writes[] = { CreateMockWrite(*req) }; |
4132 | 4054 |
4133 // 5 data frames in a single read. | 4055 // 5 data frames in a single read. |
4134 SpdySynReplyIR reply_ir(1); | 4056 scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
4135 reply_ir.SetHeader(spdy_util_.GetStatusKey(), "200"); | |
4136 reply_ir.SetHeader(spdy_util_.GetVersionKey(), "HTTP/1.1"); | |
4137 | |
4138 scoped_ptr<SpdyFrame> syn_reply(framer.SerializeFrame(reply_ir)); | |
4139 scoped_ptr<SpdyFrame> data_frame( | 4057 scoped_ptr<SpdyFrame> data_frame( |
4140 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 4058 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
4141 scoped_ptr<SpdyFrame> data_frame_fin( | 4059 scoped_ptr<SpdyFrame> data_frame_fin( |
4142 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); | 4060 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); |
4143 const SpdyFrame* frames[5] = { | 4061 const SpdyFrame* frames[5] = {reply.get(), data_frame.get(), data_frame.get(), |
4144 syn_reply.get(), | 4062 data_frame.get(), data_frame_fin.get()}; |
4145 data_frame.get(), | |
4146 data_frame.get(), | |
4147 data_frame.get(), | |
4148 data_frame_fin.get() | |
4149 }; | |
4150 char combined_frames[200]; | 4063 char combined_frames[200]; |
4151 int combined_frames_len = | 4064 int combined_frames_len = |
4152 CombineFrames(frames, arraysize(frames), | 4065 CombineFrames(frames, arraysize(frames), |
4153 combined_frames, arraysize(combined_frames)); | 4066 combined_frames, arraysize(combined_frames)); |
4154 | 4067 |
4155 MockRead reads[] = { | 4068 MockRead reads[] = { |
4156 MockRead(ASYNC, combined_frames, combined_frames_len), | 4069 MockRead(ASYNC, combined_frames, combined_frames_len), |
4157 MockRead(ASYNC, 0, 0) // EOF | 4070 MockRead(ASYNC, 0, 0) // EOF |
4158 }; | 4071 }; |
4159 | 4072 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4372 base::RunLoop().RunUntilIdle(); | 4285 base::RunLoop().RunUntilIdle(); |
4373 | 4286 |
4374 // Verify that we consumed all test data. | 4287 // Verify that we consumed all test data. |
4375 helper.VerifyDataConsumed(); | 4288 helper.VerifyDataConsumed(); |
4376 } | 4289 } |
4377 | 4290 |
4378 // Test that if the server requests persistence of settings, that we save | 4291 // Test that if the server requests persistence of settings, that we save |
4379 // the settings in the HttpServerProperties. | 4292 // the settings in the HttpServerProperties. |
4380 TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { | 4293 TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { |
4381 if (spdy_util_.spdy_version() >= SPDY4) { | 4294 if (spdy_util_.spdy_version() >= SPDY4) { |
4382 // SPDY4 doesn't support flags on individual settings, and | 4295 // SPDY4 doesn't support settings persistence. |
4383 // has no concept of settings persistence. | |
4384 return; | 4296 return; |
4385 } | 4297 } |
4386 static const SpdyHeaderInfo kSynReplyInfo = { | 4298 static const SpdyHeaderInfo kSynReplyInfo = { |
4387 SYN_REPLY, // Syn Reply | 4299 SYN_REPLY, // Syn Reply |
4388 1, // Stream ID | 4300 1, // Stream ID |
4389 0, // Associated Stream ID | 4301 0, // Associated Stream ID |
4390 ConvertRequestPriorityToSpdyPriority( | 4302 ConvertRequestPriorityToSpdyPriority( |
4391 LOWEST, spdy_util_.spdy_version()), | 4303 LOWEST, spdy_util_.spdy_version()), |
4392 kSpdyCredentialSlotUnused, | 4304 kSpdyCredentialSlotUnused, |
4393 CONTROL_FLAG_NONE, // Control Flags | 4305 CONTROL_FLAG_NONE, // Control Flags |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4480 EXPECT_TRUE(it3 != settings_map.end()); | 4392 EXPECT_TRUE(it3 != settings_map.end()); |
4481 SettingsFlagsAndValue flags_and_value3 = it3->second; | 4393 SettingsFlagsAndValue flags_and_value3 = it3->second; |
4482 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first); | 4394 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first); |
4483 EXPECT_EQ(kSampleValue3, flags_and_value3.second); | 4395 EXPECT_EQ(kSampleValue3, flags_and_value3.second); |
4484 } | 4396 } |
4485 } | 4397 } |
4486 | 4398 |
4487 // Test that when there are settings saved that they are sent back to the | 4399 // Test that when there are settings saved that they are sent back to the |
4488 // server upon session establishment. | 4400 // server upon session establishment. |
4489 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { | 4401 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { |
4490 // TODO(jgraettinger): Remove settings persistence mechanisms altogether. | 4402 if (spdy_util_.spdy_version() >= SPDY4) { |
| 4403 // SPDY4 doesn't support settings persistence. |
| 4404 return; |
| 4405 } |
4491 static const SpdyHeaderInfo kSynReplyInfo = { | 4406 static const SpdyHeaderInfo kSynReplyInfo = { |
4492 SYN_REPLY, // Syn Reply | 4407 SYN_REPLY, // Syn Reply |
4493 1, // Stream ID | 4408 1, // Stream ID |
4494 0, // Associated Stream ID | 4409 0, // Associated Stream ID |
4495 ConvertRequestPriorityToSpdyPriority( | 4410 ConvertRequestPriorityToSpdyPriority( |
4496 LOWEST, spdy_util_.spdy_version()), | 4411 LOWEST, spdy_util_.spdy_version()), |
4497 kSpdyCredentialSlotUnused, | 4412 kSpdyCredentialSlotUnused, |
4498 CONTROL_FLAG_NONE, // Control Flags | 4413 CONTROL_FLAG_NONE, // Control Flags |
4499 false, // Compressed | 4414 false, // Compressed |
4500 RST_STREAM_INVALID, // Status | 4415 RST_STREAM_INVALID, // Status |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5608 EXPECT_TRUE(data.at_read_eof()); | 5523 EXPECT_TRUE(data.at_read_eof()); |
5609 EXPECT_TRUE(data.at_write_eof()); | 5524 EXPECT_TRUE(data.at_write_eof()); |
5610 } | 5525 } |
5611 | 5526 |
5612 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { | 5527 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { |
5613 scoped_ptr<SpdyFrame> req( | 5528 scoped_ptr<SpdyFrame> req( |
5614 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5529 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
5615 scoped_ptr<SpdyFrame> rst( | 5530 scoped_ptr<SpdyFrame> rst( |
5616 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 5531 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
5617 MockWrite writes[] = { | 5532 MockWrite writes[] = { |
5618 CreateMockWrite(*req), | 5533 CreateMockWrite(*req), CreateMockWrite(*rst), |
5619 CreateMockWrite(*rst), | 5534 }; |
5620 }; | |
5621 | 5535 |
5622 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | |
5623 (*initial_headers)[spdy_util_.GetStatusKey()] = "200 OK"; | |
5624 (*initial_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | |
5625 scoped_ptr<SpdyFrame> stream1_reply( | 5536 scoped_ptr<SpdyFrame> stream1_reply( |
5626 spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(), | 5537 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
5627 false, | |
5628 1, | |
5629 LOWEST, | |
5630 SYN_REPLY, | |
5631 CONTROL_FLAG_NONE, | |
5632 0)); | |
5633 | 5538 |
5634 scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); | 5539 scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); |
5635 (*late_headers)["hello"] = "bye"; | 5540 (*late_headers)["hello"] = "bye"; |
5636 scoped_ptr<SpdyFrame> stream1_headers( | 5541 scoped_ptr<SpdyFrame> stream1_headers( |
5637 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), | 5542 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), |
5638 false, | 5543 false, |
5639 1, | 5544 1, |
5640 LOWEST, | 5545 LOWEST, |
5641 HEADERS, | 5546 HEADERS, |
5642 CONTROL_FLAG_NONE, | 5547 CONTROL_FLAG_NONE, |
(...skipping 19 matching lines...) Expand all Loading... |
5662 TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) { | 5567 TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) { |
5663 scoped_ptr<SpdyFrame> req( | 5568 scoped_ptr<SpdyFrame> req( |
5664 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5569 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
5665 scoped_ptr<SpdyFrame> rst( | 5570 scoped_ptr<SpdyFrame> rst( |
5666 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 5571 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
5667 MockWrite writes[] = { | 5572 MockWrite writes[] = { |
5668 CreateMockWrite(*req), | 5573 CreateMockWrite(*req), |
5669 CreateMockWrite(*rst), | 5574 CreateMockWrite(*rst), |
5670 }; | 5575 }; |
5671 | 5576 |
5672 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | |
5673 (*initial_headers)[spdy_util_.GetStatusKey()] = "200 OK"; | |
5674 (*initial_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | |
5675 scoped_ptr<SpdyFrame> stream1_reply( | 5577 scoped_ptr<SpdyFrame> stream1_reply( |
5676 spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(), | 5578 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
5677 false, | |
5678 1, | |
5679 LOWEST, | |
5680 SYN_REPLY, | |
5681 CONTROL_FLAG_NONE, | |
5682 0)); | |
5683 | 5579 |
5684 scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); | 5580 scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); |
5685 (*late_headers)["hello"] = "bye"; | 5581 (*late_headers)["hello"] = "bye"; |
5686 scoped_ptr<SpdyFrame> stream1_headers( | 5582 scoped_ptr<SpdyFrame> stream1_headers( |
5687 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), | 5583 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), |
5688 false, | 5584 false, |
5689 1, | 5585 1, |
5690 LOWEST, | 5586 LOWEST, |
5691 HEADERS, | 5587 HEADERS, |
5692 CONTROL_FLAG_NONE, | 5588 CONTROL_FLAG_NONE, |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6703 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6599 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
6704 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6600 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
6705 new SSLSocketDataProvider(ASYNC, OK)); | 6601 new SSLSocketDataProvider(ASYNC, OK)); |
6706 // Set to TLS_RSA_WITH_NULL_MD5 | 6602 // Set to TLS_RSA_WITH_NULL_MD5 |
6707 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6603 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
6708 | 6604 |
6709 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6605 RunTLSUsageCheckTest(ssl_provider.Pass()); |
6710 } | 6606 } |
6711 | 6607 |
6712 } // namespace net | 6608 } // namespace net |
OLD | NEW |