| 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 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 helper.VerifyDataConsumed(); | 1670 helper.VerifyDataConsumed(); |
| 1671 } | 1671 } |
| 1672 | 1672 |
| 1673 // Test that a simple PUT request works. | 1673 // Test that a simple PUT request works. |
| 1674 TEST_P(SpdyNetworkTransactionTest, Put) { | 1674 TEST_P(SpdyNetworkTransactionTest, Put) { |
| 1675 // Setup the request | 1675 // Setup the request |
| 1676 HttpRequestInfo request; | 1676 HttpRequestInfo request; |
| 1677 request.method = "PUT"; | 1677 request.method = "PUT"; |
| 1678 request.url = GURL("http://www.google.com/"); | 1678 request.url = GURL("http://www.google.com/"); |
| 1679 | 1679 |
| 1680 const SpdyHeaderInfo kSynStartHeader = { | |
| 1681 SYN_STREAM, // Kind = Syn | |
| 1682 1, // Stream ID | |
| 1683 0, // Associated stream ID | |
| 1684 ConvertRequestPriorityToSpdyPriority( | |
| 1685 LOWEST, spdy_util_.spdy_version()), | |
| 1686 kSpdyCredentialSlotUnused, | |
| 1687 CONTROL_FLAG_FIN, // Control Flags | |
| 1688 false, // Compressed | |
| 1689 RST_STREAM_INVALID, // Status | |
| 1690 NULL, // Data | |
| 1691 0, // Length | |
| 1692 DATA_FLAG_NONE // Data Flags | |
| 1693 }; | |
| 1694 scoped_ptr<SpdyHeaderBlock> put_headers( | 1680 scoped_ptr<SpdyHeaderBlock> put_headers( |
| 1695 spdy_util_.ConstructPutHeaderBlock("http://www.google.com", 0)); | 1681 spdy_util_.ConstructPutHeaderBlock("http://www.google.com", 0)); |
| 1696 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( | 1682 scoped_ptr<SpdyFrame> req( |
| 1697 kSynStartHeader, put_headers.Pass())); | 1683 spdy_util_.ConstructSpdySyn(1, *put_headers, LOWEST, false, true)); |
| 1698 MockWrite writes[] = { | 1684 MockWrite writes[] = { |
| 1699 CreateMockWrite(*req), | 1685 CreateMockWrite(*req), |
| 1700 }; | 1686 }; |
| 1701 | 1687 |
| 1688 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1702 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1689 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[] = { | 1690 MockRead reads[] = { |
| 1724 CreateMockRead(*resp), | 1691 CreateMockRead(*resp), |
| 1725 CreateMockRead(*body), | 1692 CreateMockRead(*body), |
| 1726 MockRead(ASYNC, 0, 0) // EOF | 1693 MockRead(ASYNC, 0, 0) // EOF |
| 1727 }; | 1694 }; |
| 1728 | 1695 |
| 1729 DelayedSocketData data(1, reads, arraysize(reads), | 1696 DelayedSocketData data(1, reads, arraysize(reads), |
| 1730 writes, arraysize(writes)); | 1697 writes, arraysize(writes)); |
| 1731 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 1698 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 1732 BoundNetLog(), GetParam(), NULL); | 1699 BoundNetLog(), GetParam(), NULL); |
| 1733 helper.RunToCompletion(&data); | 1700 helper.RunToCompletion(&data); |
| 1734 TransactionHelperResult out = helper.output(); | 1701 TransactionHelperResult out = helper.output(); |
| 1735 | 1702 |
| 1736 EXPECT_EQ(OK, out.rv); | 1703 EXPECT_EQ(OK, out.rv); |
| 1737 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1704 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1738 } | 1705 } |
| 1739 | 1706 |
| 1740 // Test that a simple HEAD request works. | 1707 // Test that a simple HEAD request works. |
| 1741 TEST_P(SpdyNetworkTransactionTest, Head) { | 1708 TEST_P(SpdyNetworkTransactionTest, Head) { |
| 1742 // Setup the request | 1709 // Setup the request |
| 1743 HttpRequestInfo request; | 1710 HttpRequestInfo request; |
| 1744 request.method = "HEAD"; | 1711 request.method = "HEAD"; |
| 1745 request.url = GURL("http://www.google.com/"); | 1712 request.url = GURL("http://www.google.com/"); |
| 1746 | 1713 |
| 1747 const SpdyHeaderInfo kSynStartHeader = { | |
| 1748 SYN_STREAM, // Kind = Syn | |
| 1749 1, // Stream ID | |
| 1750 0, // Associated stream ID | |
| 1751 ConvertRequestPriorityToSpdyPriority( | |
| 1752 LOWEST, spdy_util_.spdy_version()), | |
| 1753 kSpdyCredentialSlotUnused, | |
| 1754 CONTROL_FLAG_FIN, // Control Flags | |
| 1755 false, // Compressed | |
| 1756 RST_STREAM_INVALID, // Status | |
| 1757 NULL, // Data | |
| 1758 0, // Length | |
| 1759 DATA_FLAG_NONE // Data Flags | |
| 1760 }; | |
| 1761 scoped_ptr<SpdyHeaderBlock> head_headers( | 1714 scoped_ptr<SpdyHeaderBlock> head_headers( |
| 1762 spdy_util_.ConstructHeadHeaderBlock("http://www.google.com", 0)); | 1715 spdy_util_.ConstructHeadHeaderBlock("http://www.google.com", 0)); |
| 1763 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( | 1716 scoped_ptr<SpdyFrame> req( |
| 1764 kSynStartHeader, head_headers.Pass())); | 1717 spdy_util_.ConstructSpdySyn(1, *head_headers, LOWEST, false, true)); |
| 1765 MockWrite writes[] = { | 1718 MockWrite writes[] = { |
| 1766 CreateMockWrite(*req), | 1719 CreateMockWrite(*req), |
| 1767 }; | 1720 }; |
| 1768 | 1721 |
| 1722 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1769 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1723 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[] = { | 1724 MockRead reads[] = { |
| 1792 CreateMockRead(*resp), | 1725 CreateMockRead(*resp), |
| 1793 CreateMockRead(*body), | 1726 CreateMockRead(*body), |
| 1794 MockRead(ASYNC, 0, 0) // EOF | 1727 MockRead(ASYNC, 0, 0) // EOF |
| 1795 }; | 1728 }; |
| 1796 | 1729 |
| 1797 DelayedSocketData data(1, reads, arraysize(reads), | 1730 DelayedSocketData data(1, reads, arraysize(reads), |
| 1798 writes, arraysize(writes)); | 1731 writes, arraysize(writes)); |
| 1799 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 1732 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 1800 BoundNetLog(), GetParam(), NULL); | 1733 BoundNetLog(), GetParam(), NULL); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2012 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 1945 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
| 2013 // Setup the request | 1946 // Setup the request |
| 2014 HttpRequestInfo request; | 1947 HttpRequestInfo request; |
| 2015 request.method = "POST"; | 1948 request.method = "POST"; |
| 2016 request.url = GURL(kRequestUrl); | 1949 request.url = GURL(kRequestUrl); |
| 2017 // Create an empty UploadData. | 1950 // Create an empty UploadData. |
| 2018 request.upload_data_stream = NULL; | 1951 request.upload_data_stream = NULL; |
| 2019 | 1952 |
| 2020 // When request.upload_data_stream is NULL for post, content-length is | 1953 // When request.upload_data_stream is NULL for post, content-length is |
| 2021 // expected to be 0. | 1954 // expected to be 0. |
| 2022 SpdySynStreamIR syn_ir(1); | 1955 scoped_ptr<SpdyHeaderBlock> req_block( |
| 2023 syn_ir.set_name_value_block( | 1956 spdy_util_.ConstructPostHeaderBlock(kRequestUrl, 0)); |
| 2024 *spdy_util_.ConstructPostHeaderBlock(kRequestUrl, 0)); | 1957 scoped_ptr<SpdyFrame> req( |
| 2025 syn_ir.set_fin(true); // No body. | 1958 spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, false, true)); |
| 2026 syn_ir.set_priority(ConvertRequestPriorityToSpdyPriority( | |
| 2027 LOWEST, spdy_util_.spdy_version())); | |
| 2028 scoped_ptr<SpdyFrame> req(framer.SerializeFrame(syn_ir)); | |
| 2029 | 1959 |
| 2030 MockWrite writes[] = { | 1960 MockWrite writes[] = { |
| 2031 CreateMockWrite(*req), | 1961 CreateMockWrite(*req), |
| 2032 }; | 1962 }; |
| 2033 | 1963 |
| 2034 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 1964 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 2035 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1965 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 2036 MockRead reads[] = { | 1966 MockRead reads[] = { |
| 2037 CreateMockRead(*resp), | 1967 CreateMockRead(*resp), |
| 2038 CreateMockRead(*body), | 1968 CreateMockRead(*body), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2059 UploadDataStream stream(element_readers.Pass(), 0); | 1989 UploadDataStream stream(element_readers.Pass(), 0); |
| 2060 | 1990 |
| 2061 // Setup the request | 1991 // Setup the request |
| 2062 HttpRequestInfo request; | 1992 HttpRequestInfo request; |
| 2063 request.method = "POST"; | 1993 request.method = "POST"; |
| 2064 request.url = GURL(kRequestUrl); | 1994 request.url = GURL(kRequestUrl); |
| 2065 request.upload_data_stream = &stream; | 1995 request.upload_data_stream = &stream; |
| 2066 | 1996 |
| 2067 const uint64 kContentLength = 0; | 1997 const uint64 kContentLength = 0; |
| 2068 | 1998 |
| 2069 SpdySynStreamIR syn_ir(1); | 1999 scoped_ptr<SpdyHeaderBlock> req_block( |
| 2070 syn_ir.set_name_value_block( | 2000 spdy_util_.ConstructPostHeaderBlock(kRequestUrl, kContentLength)); |
| 2071 *spdy_util_.ConstructPostHeaderBlock(kRequestUrl, kContentLength)); | 2001 scoped_ptr<SpdyFrame> req( |
| 2072 syn_ir.set_fin(true); // No body. | 2002 spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, false, true)); |
| 2073 syn_ir.set_priority(ConvertRequestPriorityToSpdyPriority( | |
| 2074 LOWEST, spdy_util_.spdy_version())); | |
| 2075 scoped_ptr<SpdyFrame> req(framer.SerializeFrame(syn_ir)); | |
| 2076 | 2003 |
| 2077 MockWrite writes[] = { | 2004 MockWrite writes[] = { |
| 2078 CreateMockWrite(*req), | 2005 CreateMockWrite(*req), |
| 2079 }; | 2006 }; |
| 2080 | 2007 |
| 2081 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 2008 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 2082 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2009 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 2083 MockRead reads[] = { | 2010 MockRead reads[] = { |
| 2084 CreateMockRead(*resp), | 2011 CreateMockRead(*resp), |
| 2085 CreateMockRead(*body), | 2012 CreateMockRead(*body), |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2516 ASSERT_EQ(ERR_IO_PENDING, rv); | 2443 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 2517 data.CompleteRead(); | 2444 data.CompleteRead(); |
| 2518 | 2445 |
| 2519 // Finish running rest of tasks. | 2446 // Finish running rest of tasks. |
| 2520 base::RunLoop().RunUntilIdle(); | 2447 base::RunLoop().RunUntilIdle(); |
| 2521 helper.VerifyDataConsumed(); | 2448 helper.VerifyDataConsumed(); |
| 2522 } | 2449 } |
| 2523 | 2450 |
| 2524 // Send a spdy request to www.google.com that gets redirected to www.foo.com. | 2451 // Send a spdy request to www.google.com that gets redirected to www.foo.com. |
| 2525 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { | 2452 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { |
| 2526 const SpdyHeaderInfo kSynStartHeader = spdy_util_.MakeSpdyHeader(SYN_STREAM); | |
| 2527 scoped_ptr<SpdyHeaderBlock> headers( | 2453 scoped_ptr<SpdyHeaderBlock> headers( |
| 2528 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); | 2454 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); |
| 2529 (*headers)["user-agent"] = ""; | 2455 (*headers)["user-agent"] = ""; |
| 2530 (*headers)["accept-encoding"] = "gzip,deflate"; | 2456 (*headers)["accept-encoding"] = "gzip,deflate"; |
| 2531 scoped_ptr<SpdyHeaderBlock> headers2( | 2457 scoped_ptr<SpdyHeaderBlock> headers2( |
| 2532 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); | 2458 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); |
| 2533 (*headers2)["user-agent"] = ""; | 2459 (*headers2)["user-agent"] = ""; |
| 2534 (*headers2)["accept-encoding"] = "gzip,deflate"; | 2460 (*headers2)["accept-encoding"] = "gzip,deflate"; |
| 2535 | 2461 |
| 2536 // Setup writes/reads to www.google.com | 2462 // Setup writes/reads to www.google.com |
| 2537 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( | 2463 scoped_ptr<SpdyFrame> req( |
| 2538 kSynStartHeader, headers.Pass())); | 2464 spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, false, true)); |
| 2539 scoped_ptr<SpdyFrame> req2(spdy_util_.ConstructSpdyFrame( | 2465 scoped_ptr<SpdyFrame> req2( |
| 2540 kSynStartHeader, headers2.Pass())); | 2466 spdy_util_.ConstructSpdySyn(1, *headers2, LOWEST, false, true)); |
| 2541 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReplyRedirect(1)); | 2467 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReplyRedirect(1)); |
| 2542 MockWrite writes[] = { | 2468 MockWrite writes[] = { |
| 2543 CreateMockWrite(*req, 1), | 2469 CreateMockWrite(*req, 1), |
| 2544 }; | 2470 }; |
| 2545 MockRead reads[] = { | 2471 MockRead reads[] = { |
| 2546 CreateMockRead(*resp, 2), | 2472 CreateMockRead(*resp, 2), |
| 2547 MockRead(ASYNC, 0, 0, 3) // EOF | 2473 MockRead(ASYNC, 0, 0, 3) // EOF |
| 2548 }; | 2474 }; |
| 2549 | 2475 |
| 2550 // Setup writes/reads to www.foo.com | 2476 // Setup writes/reads to www.foo.com |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2595 } | 2521 } |
| 2596 EXPECT_TRUE(data.at_read_eof()); | 2522 EXPECT_TRUE(data.at_read_eof()); |
| 2597 EXPECT_TRUE(data.at_write_eof()); | 2523 EXPECT_TRUE(data.at_write_eof()); |
| 2598 EXPECT_TRUE(data2.at_read_eof()); | 2524 EXPECT_TRUE(data2.at_read_eof()); |
| 2599 EXPECT_TRUE(data2.at_write_eof()); | 2525 EXPECT_TRUE(data2.at_write_eof()); |
| 2600 } | 2526 } |
| 2601 | 2527 |
| 2602 // Send a spdy request to www.google.com. Get a pushed stream that redirects to | 2528 // Send a spdy request to www.google.com. Get a pushed stream that redirects to |
| 2603 // www.foo.com. | 2529 // www.foo.com. |
| 2604 TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { | 2530 TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { |
| 2605 const SpdyHeaderInfo kSynStartHeader = spdy_util_.MakeSpdyHeader(SYN_STREAM); | |
| 2606 | |
| 2607 scoped_ptr<SpdyHeaderBlock> headers( | 2531 scoped_ptr<SpdyHeaderBlock> headers( |
| 2608 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); | 2532 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); |
| 2609 (*headers)["user-agent"] = ""; | 2533 (*headers)["user-agent"] = ""; |
| 2610 (*headers)["accept-encoding"] = "gzip,deflate"; | 2534 (*headers)["accept-encoding"] = "gzip,deflate"; |
| 2611 | 2535 |
| 2612 // Setup writes/reads to www.google.com | 2536 // Setup writes/reads to www.google.com |
| 2613 scoped_ptr<SpdyFrame> req( | 2537 scoped_ptr<SpdyFrame> req( |
| 2614 spdy_util_.ConstructSpdyFrame(kSynStartHeader, headers.Pass())); | 2538 spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, false, true)); |
| 2615 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2539 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2616 scoped_ptr<SpdyFrame> rep( | 2540 scoped_ptr<SpdyFrame> rep( |
| 2617 spdy_util_.ConstructSpdyPush(NULL, | 2541 spdy_util_.ConstructSpdyPush(NULL, |
| 2618 0, | 2542 0, |
| 2619 2, | 2543 2, |
| 2620 1, | 2544 1, |
| 2621 "http://www.google.com/foo.dat", | 2545 "http://www.google.com/foo.dat", |
| 2622 "301 Moved Permanently", | 2546 "301 Moved Permanently", |
| 2623 "http://www.foo.com/index.php")); | 2547 "http://www.foo.com/index.php")); |
| 2624 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2548 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2635 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause | 2559 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause |
| 2636 MockRead(ASYNC, 0, 0, 7) // EOF | 2560 MockRead(ASYNC, 0, 0, 7) // EOF |
| 2637 }; | 2561 }; |
| 2638 | 2562 |
| 2639 // Setup writes/reads to www.foo.com | 2563 // Setup writes/reads to www.foo.com |
| 2640 scoped_ptr<SpdyHeaderBlock> headers2( | 2564 scoped_ptr<SpdyHeaderBlock> headers2( |
| 2641 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); | 2565 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); |
| 2642 (*headers2)["user-agent"] = ""; | 2566 (*headers2)["user-agent"] = ""; |
| 2643 (*headers2)["accept-encoding"] = "gzip,deflate"; | 2567 (*headers2)["accept-encoding"] = "gzip,deflate"; |
| 2644 scoped_ptr<SpdyFrame> req2( | 2568 scoped_ptr<SpdyFrame> req2( |
| 2645 spdy_util_.ConstructSpdyFrame(kSynStartHeader, headers2.Pass())); | 2569 spdy_util_.ConstructSpdySyn(1, *headers2, LOWEST, false, true)); |
| 2646 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2570 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2647 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2571 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 2648 MockWrite writes2[] = { | 2572 MockWrite writes2[] = { |
| 2649 CreateMockWrite(*req2, 1), | 2573 CreateMockWrite(*req2, 1), |
| 2650 }; | 2574 }; |
| 2651 MockRead reads2[] = { | 2575 MockRead reads2[] = { |
| 2652 CreateMockRead(*resp2, 2), | 2576 CreateMockRead(*resp2, 2), |
| 2653 CreateMockRead(*body2, 3), | 2577 CreateMockRead(*body2, 3), |
| 2654 MockRead(ASYNC, 0, 0, 5) // EOF | 2578 MockRead(ASYNC, 0, 0, 5) // EOF |
| 2655 }; | 2579 }; |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 header_block[name] += value; | 3288 header_block[name] += value; |
| 3365 } | 3289 } |
| 3366 } | 3290 } |
| 3367 EXPECT_EQ(test_cases[i].expected_headers, header_block); | 3291 EXPECT_EQ(test_cases[i].expected_headers, header_block); |
| 3368 } | 3292 } |
| 3369 } | 3293 } |
| 3370 | 3294 |
| 3371 // Verify that various SynReply headers parse vary fields correctly | 3295 // Verify that various SynReply headers parse vary fields correctly |
| 3372 // through the HTTP layer, and the response matches the request. | 3296 // through the HTTP layer, and the response matches the request. |
| 3373 TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { | 3297 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: | 3298 // Modify the following data to change/add test cases: |
| 3389 struct SynReplyTests { | 3299 struct SynReplyTests { |
| 3390 const SpdyHeaderInfo* syn_reply; | |
| 3391 bool vary_matches; | 3300 bool vary_matches; |
| 3392 int num_headers[2]; | 3301 int num_headers[2]; |
| 3393 const char* extra_headers[2][16]; | 3302 const char* extra_headers[2][16]; |
| 3394 } test_cases[] = { | 3303 } test_cases[] = { |
| 3395 // Test the case of a multi-valued cookie. When the value is delimited | 3304 // 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. | 3305 // with NUL characters, it needs to be unfolded into multiple headers. |
| 3397 { | 3306 { |
| 3398 &syn_reply_info, | |
| 3399 true, | 3307 true, |
| 3400 { 1, 4 }, | 3308 { 1, 4 }, |
| 3401 { { "cookie", "val1,val2", | 3309 { { "cookie", "val1,val2", |
| 3402 NULL | 3310 NULL |
| 3403 }, | 3311 }, |
| 3404 { "vary", "cookie", | 3312 { "vary", "cookie", |
| 3405 spdy_util_.GetStatusKey(), "200", | 3313 spdy_util_.GetStatusKey(), "200", |
| 3406 spdy_util_.GetPathKey(), "/index.php", | 3314 spdy_util_.GetPathKey(), "/index.php", |
| 3407 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3315 spdy_util_.GetVersionKey(), "HTTP/1.1", |
| 3408 NULL | 3316 NULL |
| 3409 } | 3317 } |
| 3410 } | 3318 } |
| 3411 }, { // Multiple vary fields. | 3319 }, { // Multiple vary fields. |
| 3412 &syn_reply_info, | |
| 3413 true, | 3320 true, |
| 3414 { 2, 5 }, | 3321 { 2, 5 }, |
| 3415 { { "friend", "barney", | 3322 { { "friend", "barney", |
| 3416 "enemy", "snaggletooth", | 3323 "enemy", "snaggletooth", |
| 3417 NULL | 3324 NULL |
| 3418 }, | 3325 }, |
| 3419 { "vary", "friend", | 3326 { "vary", "friend", |
| 3420 "vary", "enemy", | 3327 "vary", "enemy", |
| 3421 spdy_util_.GetStatusKey(), "200", | 3328 spdy_util_.GetStatusKey(), "200", |
| 3422 spdy_util_.GetPathKey(), "/index.php", | 3329 spdy_util_.GetPathKey(), "/index.php", |
| 3423 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3330 spdy_util_.GetVersionKey(), "HTTP/1.1", |
| 3424 NULL | 3331 NULL |
| 3425 } | 3332 } |
| 3426 } | 3333 } |
| 3427 }, { // Test a '*' vary field. | 3334 }, { // Test a '*' vary field. |
| 3428 &syn_reply_info, | |
| 3429 false, | 3335 false, |
| 3430 { 1, 4 }, | 3336 { 1, 4 }, |
| 3431 { { "cookie", "val1,val2", | 3337 { { "cookie", "val1,val2", |
| 3432 NULL | 3338 NULL |
| 3433 }, | 3339 }, |
| 3434 { "vary", "*", | 3340 { "vary", "*", |
| 3435 spdy_util_.GetStatusKey(), "200", | 3341 spdy_util_.GetStatusKey(), "200", |
| 3436 spdy_util_.GetPathKey(), "/index.php", | 3342 spdy_util_.GetPathKey(), "/index.php", |
| 3437 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3343 spdy_util_.GetVersionKey(), "HTTP/1.1", |
| 3438 NULL | 3344 NULL |
| 3439 } | 3345 } |
| 3440 } | 3346 } |
| 3441 }, { // Multiple comma-separated vary fields. | 3347 }, { // Multiple comma-separated vary fields. |
| 3442 &syn_reply_info, | |
| 3443 true, | 3348 true, |
| 3444 { 2, 4 }, | 3349 { 2, 4 }, |
| 3445 { { "friend", "barney", | 3350 { { "friend", "barney", |
| 3446 "enemy", "snaggletooth", | 3351 "enemy", "snaggletooth", |
| 3447 NULL | 3352 NULL |
| 3448 }, | 3353 }, |
| 3449 { "vary", "friend,enemy", | 3354 { "vary", "friend,enemy", |
| 3450 spdy_util_.GetStatusKey(), "200", | 3355 spdy_util_.GetStatusKey(), "200", |
| 3451 spdy_util_.GetPathKey(), "/index.php", | 3356 spdy_util_.GetPathKey(), "/index.php", |
| 3452 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3357 spdy_util_.GetVersionKey(), "HTTP/1.1", |
| 3453 NULL | 3358 NULL |
| 3454 } | 3359 } |
| 3455 } | 3360 } |
| 3456 } | 3361 } |
| 3457 }; | 3362 }; |
| 3458 | 3363 |
| 3459 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 3364 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 3460 // Construct the request. | 3365 // Construct the request. |
| 3461 scoped_ptr<SpdyFrame> frame_req( | 3366 scoped_ptr<SpdyFrame> frame_req( |
| 3462 spdy_util_.ConstructSpdyGet(test_cases[i].extra_headers[0], | 3367 spdy_util_.ConstructSpdyGet(test_cases[i].extra_headers[0], |
| 3463 test_cases[i].num_headers[0], | 3368 test_cases[i].num_headers[0], |
| 3464 false, 1, LOWEST, true)); | 3369 false, 1, LOWEST, true)); |
| 3465 | 3370 |
| 3466 MockWrite writes[] = { | 3371 MockWrite writes[] = { |
| 3467 CreateMockWrite(*frame_req), | 3372 CreateMockWrite(*frame_req), |
| 3468 }; | 3373 }; |
| 3469 | 3374 |
| 3470 // Construct the reply. | 3375 // Construct the reply. |
| 3376 SpdyHeaderBlock reply_headers; |
| 3377 AppendToHeaderBlock(test_cases[i].extra_headers[1], |
| 3378 test_cases[i].num_headers[1], |
| 3379 &reply_headers); |
| 3471 scoped_ptr<SpdyFrame> frame_reply( | 3380 scoped_ptr<SpdyFrame> frame_reply( |
| 3472 spdy_util_.ConstructSpdyFrame(*test_cases[i].syn_reply, | 3381 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 | 3382 |
| 3478 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3383 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3479 MockRead reads[] = { | 3384 MockRead reads[] = { |
| 3480 CreateMockRead(*frame_reply), | 3385 CreateMockRead(*frame_reply), |
| 3481 CreateMockRead(*body), | 3386 CreateMockRead(*body), |
| 3482 MockRead(ASYNC, 0, 0) // EOF | 3387 MockRead(ASYNC, 0, 0) // EOF |
| 3483 }; | 3388 }; |
| 3484 | 3389 |
| 3485 // Attach the headers to the request. | 3390 // Attach the headers to the request. |
| 3486 int header_count = test_cases[i].num_headers[0]; | 3391 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; | 3426 void* iter = NULL; |
| 3522 std::string name, value, lines; | 3427 std::string name, value, lines; |
| 3523 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { | 3428 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { |
| 3524 lines.append(name); | 3429 lines.append(name); |
| 3525 lines.append(": "); | 3430 lines.append(": "); |
| 3526 lines.append(value); | 3431 lines.append(value); |
| 3527 lines.append("\n"); | 3432 lines.append("\n"); |
| 3528 } | 3433 } |
| 3529 | 3434 |
| 3530 // Construct the expected header reply string. | 3435 // 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 = | 3436 std::string expected_reply = |
| 3536 spdy_util_.ConstructSpdyReplyString(reply_headers); | 3437 spdy_util_.ConstructSpdyReplyString(reply_headers); |
| 3537 EXPECT_EQ(expected_reply, lines) << i; | 3438 EXPECT_EQ(expected_reply, lines) << i; |
| 3538 } | 3439 } |
| 3539 } | 3440 } |
| 3540 | 3441 |
| 3541 // Verify that we don't crash on invalid SynReply responses. | 3442 // Verify that we don't crash on invalid SynReply responses. |
| 3542 TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { | 3443 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 { | 3444 struct InvalidSynReplyTests { |
| 3559 int num_headers; | 3445 int num_headers; |
| 3560 const char* headers[10]; | 3446 const char* headers[10]; |
| 3561 } test_cases[] = { | 3447 } test_cases[] = { |
| 3562 // SYN_REPLY missing status header | 3448 // SYN_REPLY missing status header |
| 3563 { 4, | 3449 { 4, |
| 3564 { "cookie", "val1", | 3450 { "cookie", "val1", |
| 3565 "cookie", "val2", | 3451 "cookie", "val2", |
| 3566 spdy_util_.GetPathKey(), "/index.php", | 3452 spdy_util_.GetPathKey(), "/index.php", |
| 3567 spdy_util_.GetVersionKey(), "HTTP/1.1", | 3453 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) { | 3468 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 3583 scoped_ptr<SpdyFrame> req( | 3469 scoped_ptr<SpdyFrame> req( |
| 3584 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3470 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3585 scoped_ptr<SpdyFrame> rst( | 3471 scoped_ptr<SpdyFrame> rst( |
| 3586 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 3472 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 3587 MockWrite writes[] = { | 3473 MockWrite writes[] = { |
| 3588 CreateMockWrite(*req), | 3474 CreateMockWrite(*req), |
| 3589 CreateMockWrite(*rst), | 3475 CreateMockWrite(*rst), |
| 3590 }; | 3476 }; |
| 3591 | 3477 |
| 3592 scoped_ptr<SpdyFrame> resp( | 3478 // Construct the reply. |
| 3593 spdy_util_.ConstructSpdyFrame(kSynStartHeader, | 3479 SpdyHeaderBlock reply_headers; |
| 3594 NULL, 0, | 3480 AppendToHeaderBlock( |
| 3595 test_cases[i].headers, | 3481 test_cases[i].headers, test_cases[i].num_headers, &reply_headers); |
| 3596 test_cases[i].num_headers)); | 3482 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyReply(1, reply_headers)); |
| 3597 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | |
| 3598 MockRead reads[] = { | 3483 MockRead reads[] = { |
| 3599 CreateMockRead(*resp), | 3484 CreateMockRead(*resp), |
| 3600 MockRead(ASYNC, 0, 0) // EOF | 3485 MockRead(ASYNC, 0, 0) // EOF |
| 3601 }; | 3486 }; |
| 3602 | 3487 |
| 3603 DelayedSocketData data(1, reads, arraysize(reads), | 3488 DelayedSocketData data(1, reads, arraysize(reads), |
| 3604 writes, arraysize(writes)); | 3489 writes, arraysize(writes)); |
| 3605 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3490 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3606 BoundNetLog(), GetParam(), NULL); | 3491 BoundNetLog(), GetParam(), NULL); |
| 3607 helper.RunToCompletion(&data); | 3492 helper.RunToCompletion(&data); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4124 | 4009 |
| 4125 // Verify the case where we buffer data but read it after it has been buffered. | 4010 // Verify the case where we buffer data but read it after it has been buffered. |
| 4126 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { | 4011 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { |
| 4127 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4012 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
| 4128 | 4013 |
| 4129 scoped_ptr<SpdyFrame> req( | 4014 scoped_ptr<SpdyFrame> req( |
| 4130 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4015 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4131 MockWrite writes[] = { CreateMockWrite(*req) }; | 4016 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4132 | 4017 |
| 4133 // 5 data frames in a single read. | 4018 // 5 data frames in a single read. |
| 4134 SpdySynReplyIR reply_ir(1); | 4019 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( | 4020 scoped_ptr<SpdyFrame> data_frame( |
| 4140 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 4021 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
| 4141 scoped_ptr<SpdyFrame> data_frame_fin( | 4022 scoped_ptr<SpdyFrame> data_frame_fin( |
| 4142 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); | 4023 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); |
| 4143 const SpdyFrame* frames[5] = { | 4024 const SpdyFrame* frames[5] = {reply.get(), data_frame.get(), data_frame.get(), |
| 4144 syn_reply.get(), | 4025 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]; | 4026 char combined_frames[200]; |
| 4151 int combined_frames_len = | 4027 int combined_frames_len = |
| 4152 CombineFrames(frames, arraysize(frames), | 4028 CombineFrames(frames, arraysize(frames), |
| 4153 combined_frames, arraysize(combined_frames)); | 4029 combined_frames, arraysize(combined_frames)); |
| 4154 | 4030 |
| 4155 MockRead reads[] = { | 4031 MockRead reads[] = { |
| 4156 MockRead(ASYNC, combined_frames, combined_frames_len), | 4032 MockRead(ASYNC, combined_frames, combined_frames_len), |
| 4157 MockRead(ASYNC, 0, 0) // EOF | 4033 MockRead(ASYNC, 0, 0) // EOF |
| 4158 }; | 4034 }; |
| 4159 | 4035 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4372 base::RunLoop().RunUntilIdle(); | 4248 base::RunLoop().RunUntilIdle(); |
| 4373 | 4249 |
| 4374 // Verify that we consumed all test data. | 4250 // Verify that we consumed all test data. |
| 4375 helper.VerifyDataConsumed(); | 4251 helper.VerifyDataConsumed(); |
| 4376 } | 4252 } |
| 4377 | 4253 |
| 4378 // Test that if the server requests persistence of settings, that we save | 4254 // Test that if the server requests persistence of settings, that we save |
| 4379 // the settings in the HttpServerProperties. | 4255 // the settings in the HttpServerProperties. |
| 4380 TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { | 4256 TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { |
| 4381 if (spdy_util_.spdy_version() >= SPDY4) { | 4257 if (spdy_util_.spdy_version() >= SPDY4) { |
| 4382 // SPDY4 doesn't support flags on individual settings, and | 4258 // SPDY4 doesn't support settings persistence. |
| 4383 // has no concept of settings persistence. | |
| 4384 return; | 4259 return; |
| 4385 } | 4260 } |
| 4386 static const SpdyHeaderInfo kSynReplyInfo = { | 4261 static const SpdyHeaderInfo kSynReplyInfo = { |
| 4387 SYN_REPLY, // Syn Reply | 4262 SYN_REPLY, // Syn Reply |
| 4388 1, // Stream ID | 4263 1, // Stream ID |
| 4389 0, // Associated Stream ID | 4264 0, // Associated Stream ID |
| 4390 ConvertRequestPriorityToSpdyPriority( | 4265 ConvertRequestPriorityToSpdyPriority( |
| 4391 LOWEST, spdy_util_.spdy_version()), | 4266 LOWEST, spdy_util_.spdy_version()), |
| 4392 kSpdyCredentialSlotUnused, | 4267 kSpdyCredentialSlotUnused, |
| 4393 CONTROL_FLAG_NONE, // Control Flags | 4268 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()); | 4355 EXPECT_TRUE(it3 != settings_map.end()); |
| 4481 SettingsFlagsAndValue flags_and_value3 = it3->second; | 4356 SettingsFlagsAndValue flags_and_value3 = it3->second; |
| 4482 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first); | 4357 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first); |
| 4483 EXPECT_EQ(kSampleValue3, flags_and_value3.second); | 4358 EXPECT_EQ(kSampleValue3, flags_and_value3.second); |
| 4484 } | 4359 } |
| 4485 } | 4360 } |
| 4486 | 4361 |
| 4487 // Test that when there are settings saved that they are sent back to the | 4362 // Test that when there are settings saved that they are sent back to the |
| 4488 // server upon session establishment. | 4363 // server upon session establishment. |
| 4489 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { | 4364 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { |
| 4490 // TODO(jgraettinger): Remove settings persistence mechanisms altogether. | 4365 if (spdy_util_.spdy_version() >= SPDY4) { |
| 4366 // SPDY4 doesn't support settings persistence. |
| 4367 return; |
| 4368 } |
| 4491 static const SpdyHeaderInfo kSynReplyInfo = { | 4369 static const SpdyHeaderInfo kSynReplyInfo = { |
| 4492 SYN_REPLY, // Syn Reply | 4370 SYN_REPLY, // Syn Reply |
| 4493 1, // Stream ID | 4371 1, // Stream ID |
| 4494 0, // Associated Stream ID | 4372 0, // Associated Stream ID |
| 4495 ConvertRequestPriorityToSpdyPriority( | 4373 ConvertRequestPriorityToSpdyPriority( |
| 4496 LOWEST, spdy_util_.spdy_version()), | 4374 LOWEST, spdy_util_.spdy_version()), |
| 4497 kSpdyCredentialSlotUnused, | 4375 kSpdyCredentialSlotUnused, |
| 4498 CONTROL_FLAG_NONE, // Control Flags | 4376 CONTROL_FLAG_NONE, // Control Flags |
| 4499 false, // Compressed | 4377 false, // Compressed |
| 4500 RST_STREAM_INVALID, // Status | 4378 RST_STREAM_INVALID, // Status |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5608 EXPECT_TRUE(data.at_read_eof()); | 5486 EXPECT_TRUE(data.at_read_eof()); |
| 5609 EXPECT_TRUE(data.at_write_eof()); | 5487 EXPECT_TRUE(data.at_write_eof()); |
| 5610 } | 5488 } |
| 5611 | 5489 |
| 5612 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { | 5490 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { |
| 5613 scoped_ptr<SpdyFrame> req( | 5491 scoped_ptr<SpdyFrame> req( |
| 5614 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5492 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5615 scoped_ptr<SpdyFrame> rst( | 5493 scoped_ptr<SpdyFrame> rst( |
| 5616 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 5494 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 5617 MockWrite writes[] = { | 5495 MockWrite writes[] = { |
| 5618 CreateMockWrite(*req), | 5496 CreateMockWrite(*req), CreateMockWrite(*rst), |
| 5619 CreateMockWrite(*rst), | 5497 }; |
| 5620 }; | |
| 5621 | 5498 |
| 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( | 5499 scoped_ptr<SpdyFrame> stream1_reply( |
| 5626 spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(), | 5500 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5627 false, | |
| 5628 1, | |
| 5629 LOWEST, | |
| 5630 SYN_REPLY, | |
| 5631 CONTROL_FLAG_NONE, | |
| 5632 0)); | |
| 5633 | 5501 |
| 5634 scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); | 5502 scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); |
| 5635 (*late_headers)["hello"] = "bye"; | 5503 (*late_headers)["hello"] = "bye"; |
| 5636 scoped_ptr<SpdyFrame> stream1_headers( | 5504 scoped_ptr<SpdyFrame> stream1_headers( |
| 5637 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), | 5505 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), |
| 5638 false, | 5506 false, |
| 5639 1, | 5507 1, |
| 5640 LOWEST, | 5508 LOWEST, |
| 5641 HEADERS, | 5509 HEADERS, |
| 5642 CONTROL_FLAG_NONE, | 5510 CONTROL_FLAG_NONE, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5662 TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) { | 5530 TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) { |
| 5663 scoped_ptr<SpdyFrame> req( | 5531 scoped_ptr<SpdyFrame> req( |
| 5664 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5532 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5665 scoped_ptr<SpdyFrame> rst( | 5533 scoped_ptr<SpdyFrame> rst( |
| 5666 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 5534 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 5667 MockWrite writes[] = { | 5535 MockWrite writes[] = { |
| 5668 CreateMockWrite(*req), | 5536 CreateMockWrite(*req), |
| 5669 CreateMockWrite(*rst), | 5537 CreateMockWrite(*rst), |
| 5670 }; | 5538 }; |
| 5671 | 5539 |
| 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( | 5540 scoped_ptr<SpdyFrame> stream1_reply( |
| 5676 spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(), | 5541 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5677 false, | |
| 5678 1, | |
| 5679 LOWEST, | |
| 5680 SYN_REPLY, | |
| 5681 CONTROL_FLAG_NONE, | |
| 5682 0)); | |
| 5683 | 5542 |
| 5684 scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); | 5543 scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); |
| 5685 (*late_headers)["hello"] = "bye"; | 5544 (*late_headers)["hello"] = "bye"; |
| 5686 scoped_ptr<SpdyFrame> stream1_headers( | 5545 scoped_ptr<SpdyFrame> stream1_headers( |
| 5687 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), | 5546 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), |
| 5688 false, | 5547 false, |
| 5689 1, | 5548 1, |
| 5690 LOWEST, | 5549 LOWEST, |
| 5691 HEADERS, | 5550 HEADERS, |
| 5692 CONTROL_FLAG_NONE, | 5551 CONTROL_FLAG_NONE, |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6703 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6562 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
| 6704 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6563 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
| 6705 new SSLSocketDataProvider(ASYNC, OK)); | 6564 new SSLSocketDataProvider(ASYNC, OK)); |
| 6706 // Set to TLS_RSA_WITH_NULL_MD5 | 6565 // Set to TLS_RSA_WITH_NULL_MD5 |
| 6707 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6566 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
| 6708 | 6567 |
| 6709 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6568 RunTLSUsageCheckTest(ssl_provider.Pass()); |
| 6710 } | 6569 } |
| 6711 | 6570 |
| 6712 } // namespace net | 6571 } // namespace net |
| OLD | NEW |