| 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 "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "net/spdy/spdy_test_utils.h" | 30 #include "net/spdy/spdy_test_utils.h" |
| 31 #include "net/url_request/url_request_test_util.h" | 31 #include "net/url_request/url_request_test_util.h" |
| 32 #include "testing/platform_test.h" | 32 #include "testing/platform_test.h" |
| 33 | 33 |
| 34 using namespace net::test_spdy3; | 34 using namespace net::test_spdy3; |
| 35 | 35 |
| 36 //----------------------------------------------------------------------------- | 36 //----------------------------------------------------------------------------- |
| 37 | 37 |
| 38 namespace net { | 38 namespace net { |
| 39 | 39 |
| 40 namespace { |
| 41 const char kRequestUrl[] = "http://www.google.com/"; |
| 42 } // namespace |
| 43 |
| 40 enum SpdyNetworkTransactionSpdy3TestTypes { | 44 enum SpdyNetworkTransactionSpdy3TestTypes { |
| 41 SPDYNPN, | 45 SPDYNPN, |
| 42 SPDYNOSSL, | 46 SPDYNOSSL, |
| 43 SPDYSSL, | 47 SPDYSSL, |
| 44 }; | 48 }; |
| 45 | 49 |
| 46 class SpdyNetworkTransactionSpdy3Test | 50 class SpdyNetworkTransactionSpdy3Test |
| 47 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy3TestTypes> { | 51 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy3TestTypes> { |
| 48 protected: | 52 protected: |
| 49 | 53 |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 DATA_FLAG_NONE // Data Flags | 1504 DATA_FLAG_NONE // Data Flags |
| 1501 }; | 1505 }; |
| 1502 const char* const kPutHeaders[] = { | 1506 const char* const kPutHeaders[] = { |
| 1503 ":method", "PUT", | 1507 ":method", "PUT", |
| 1504 ":path", "/", | 1508 ":path", "/", |
| 1505 ":host", "www.google.com", | 1509 ":host", "www.google.com", |
| 1506 ":scheme", "http", | 1510 ":scheme", "http", |
| 1507 ":version", "HTTP/1.1", | 1511 ":version", "HTTP/1.1", |
| 1508 "content-length", "0" | 1512 "content-length", "0" |
| 1509 }; | 1513 }; |
| 1510 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, | 1514 scoped_ptr<SpdyFrame> req(ConstructSpdyFrame(kSynStartHeader, NULL, 0, |
| 1511 kPutHeaders, arraysize(kPutHeaders) / 2)); | 1515 kPutHeaders, arraysize(kPutHeaders) / 2)); |
| 1512 MockWrite writes[] = { | 1516 MockWrite writes[] = { |
| 1513 CreateMockWrite(*req) | 1517 CreateMockWrite(*req) |
| 1514 }; | 1518 }; |
| 1515 | 1519 |
| 1516 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1520 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1517 const SpdyHeaderInfo kSynReplyHeader = { | 1521 const SpdyHeaderInfo kSynReplyHeader = { |
| 1518 SYN_REPLY, // Kind = SynReply | 1522 SYN_REPLY, // Kind = SynReply |
| 1519 1, // Stream ID | 1523 1, // Stream ID |
| 1520 0, // Associated stream ID | 1524 0, // Associated stream ID |
| 1521 ConvertRequestPriorityToSpdyPriority(LOWEST, 3), // Priority | 1525 ConvertRequestPriorityToSpdyPriority(LOWEST, 3), // Priority |
| 1522 0, // Credential Slot | 1526 0, // Credential Slot |
| 1523 CONTROL_FLAG_NONE, // Control Flags | 1527 CONTROL_FLAG_NONE, // Control Flags |
| 1524 false, // Compressed | 1528 false, // Compressed |
| 1525 RST_STREAM_INVALID, // Status | 1529 RST_STREAM_INVALID, // Status |
| 1526 NULL, // Data | 1530 NULL, // Data |
| 1527 0, // Length | 1531 0, // Length |
| 1528 DATA_FLAG_NONE // Data Flags | 1532 DATA_FLAG_NONE // Data Flags |
| 1529 }; | 1533 }; |
| 1530 static const char* const kStandardRespHeaders[] = { | 1534 static const char* const kStandardRespHeaders[] = { |
| 1531 ":status", "200", | 1535 ":status", "200", |
| 1532 ":version", "HTTP/1.1" | 1536 ":version", "HTTP/1.1" |
| 1533 "content-length", "1234" | 1537 "content-length", "1234" |
| 1534 }; | 1538 }; |
| 1535 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, | 1539 scoped_ptr<SpdyFrame> resp(ConstructSpdyFrame(kSynReplyHeader, |
| 1536 NULL, 0, kStandardRespHeaders, arraysize(kStandardRespHeaders) / 2)); | 1540 NULL, 0, kStandardRespHeaders, arraysize(kStandardRespHeaders) / 2)); |
| 1537 MockRead reads[] = { | 1541 MockRead reads[] = { |
| 1538 CreateMockRead(*resp), | 1542 CreateMockRead(*resp), |
| 1539 CreateMockRead(*body), | 1543 CreateMockRead(*body), |
| 1540 MockRead(ASYNC, 0, 0) // EOF | 1544 MockRead(ASYNC, 0, 0) // EOF |
| 1541 }; | 1545 }; |
| 1542 | 1546 |
| 1543 DelayedSocketData data(1, reads, arraysize(reads), | 1547 DelayedSocketData data(1, reads, arraysize(reads), |
| 1544 writes, arraysize(writes)); | 1548 writes, arraysize(writes)); |
| 1545 NormalSpdyTransactionHelper helper(request, | 1549 NormalSpdyTransactionHelper helper(request, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1572 DATA_FLAG_NONE // Data Flags | 1576 DATA_FLAG_NONE // Data Flags |
| 1573 }; | 1577 }; |
| 1574 const char* const kHeadHeaders[] = { | 1578 const char* const kHeadHeaders[] = { |
| 1575 ":method", "HEAD", | 1579 ":method", "HEAD", |
| 1576 ":path", "/", | 1580 ":path", "/", |
| 1577 ":host", "www.google.com", | 1581 ":host", "www.google.com", |
| 1578 ":scheme", "http", | 1582 ":scheme", "http", |
| 1579 ":version", "HTTP/1.1", | 1583 ":version", "HTTP/1.1", |
| 1580 "content-length", "0" | 1584 "content-length", "0" |
| 1581 }; | 1585 }; |
| 1582 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, | 1586 scoped_ptr<SpdyFrame> req(ConstructSpdyFrame(kSynStartHeader, NULL, 0, |
| 1583 kHeadHeaders, arraysize(kHeadHeaders) / 2)); | 1587 kHeadHeaders, arraysize(kHeadHeaders) / 2)); |
| 1584 MockWrite writes[] = { | 1588 MockWrite writes[] = { |
| 1585 CreateMockWrite(*req) | 1589 CreateMockWrite(*req) |
| 1586 }; | 1590 }; |
| 1587 | 1591 |
| 1588 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1592 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1589 const SpdyHeaderInfo kSynReplyHeader = { | 1593 const SpdyHeaderInfo kSynReplyHeader = { |
| 1590 SYN_REPLY, // Kind = SynReply | 1594 SYN_REPLY, // Kind = SynReply |
| 1591 1, // Stream ID | 1595 1, // Stream ID |
| 1592 0, // Associated stream ID | 1596 0, // Associated stream ID |
| 1593 ConvertRequestPriorityToSpdyPriority(LOWEST, 3), // Priority | 1597 ConvertRequestPriorityToSpdyPriority(LOWEST, 3), // Priority |
| 1594 0, // Credential Slot | 1598 0, // Credential Slot |
| 1595 CONTROL_FLAG_NONE, // Control Flags | 1599 CONTROL_FLAG_NONE, // Control Flags |
| 1596 false, // Compressed | 1600 false, // Compressed |
| 1597 RST_STREAM_INVALID, // Status | 1601 RST_STREAM_INVALID, // Status |
| 1598 NULL, // Data | 1602 NULL, // Data |
| 1599 0, // Length | 1603 0, // Length |
| 1600 DATA_FLAG_NONE // Data Flags | 1604 DATA_FLAG_NONE // Data Flags |
| 1601 }; | 1605 }; |
| 1602 static const char* const kStandardRespHeaders[] = { | 1606 static const char* const kStandardRespHeaders[] = { |
| 1603 ":status", "200", | 1607 ":status", "200", |
| 1604 ":version", "HTTP/1.1" | 1608 ":version", "HTTP/1.1" |
| 1605 "content-length", "1234" | 1609 "content-length", "1234" |
| 1606 }; | 1610 }; |
| 1607 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, | 1611 scoped_ptr<SpdyFrame> resp(ConstructSpdyFrame(kSynReplyHeader, |
| 1608 NULL, 0, kStandardRespHeaders, arraysize(kStandardRespHeaders) / 2)); | 1612 NULL, 0, kStandardRespHeaders, arraysize(kStandardRespHeaders) / 2)); |
| 1609 MockRead reads[] = { | 1613 MockRead reads[] = { |
| 1610 CreateMockRead(*resp), | 1614 CreateMockRead(*resp), |
| 1611 CreateMockRead(*body), | 1615 CreateMockRead(*body), |
| 1612 MockRead(ASYNC, 0, 0) // EOF | 1616 MockRead(ASYNC, 0, 0) // EOF |
| 1613 }; | 1617 }; |
| 1614 | 1618 |
| 1615 DelayedSocketData data(1, reads, arraysize(reads), | 1619 DelayedSocketData data(1, reads, arraysize(reads), |
| 1616 writes, arraysize(writes)); | 1620 writes, arraysize(writes)); |
| 1617 NormalSpdyTransactionHelper helper(request, | 1621 NormalSpdyTransactionHelper helper(request, |
| 1618 BoundNetLog(), GetParam(), NULL); | 1622 BoundNetLog(), GetParam(), NULL); |
| 1619 helper.RunToCompletion(&data); | 1623 helper.RunToCompletion(&data); |
| 1620 TransactionHelperResult out = helper.output(); | 1624 TransactionHelperResult out = helper.output(); |
| 1621 | 1625 |
| 1622 EXPECT_EQ(OK, out.rv); | 1626 EXPECT_EQ(OK, out.rv); |
| 1623 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1627 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1624 } | 1628 } |
| 1625 | 1629 |
| 1626 // Test that a simple POST works. | 1630 // Test that a simple POST works. |
| 1627 TEST_P(SpdyNetworkTransactionSpdy3Test, Post) { | 1631 TEST_P(SpdyNetworkTransactionSpdy3Test, Post) { |
| 1628 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); | 1632 scoped_ptr<SpdyFrame> req( |
| 1633 ConstructSpdyPost(kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1629 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1634 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1630 MockWrite writes[] = { | 1635 MockWrite writes[] = { |
| 1631 CreateMockWrite(*req), | 1636 CreateMockWrite(*req), |
| 1632 CreateMockWrite(*body), // POST upload frame | 1637 CreateMockWrite(*body), // POST upload frame |
| 1633 }; | 1638 }; |
| 1634 | 1639 |
| 1635 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | 1640 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| 1636 MockRead reads[] = { | 1641 MockRead reads[] = { |
| 1637 CreateMockRead(*resp), | 1642 CreateMockRead(*resp), |
| 1638 CreateMockRead(*body), | 1643 CreateMockRead(*body), |
| 1639 MockRead(ASYNC, 0, 0) // EOF | 1644 MockRead(ASYNC, 0, 0) // EOF |
| 1640 }; | 1645 }; |
| 1641 | 1646 |
| 1642 DelayedSocketData data(2, reads, arraysize(reads), | 1647 DelayedSocketData data(2, reads, arraysize(reads), |
| 1643 writes, arraysize(writes)); | 1648 writes, arraysize(writes)); |
| 1644 NormalSpdyTransactionHelper helper(CreatePostRequest(), | 1649 NormalSpdyTransactionHelper helper(CreatePostRequest(), |
| 1645 BoundNetLog(), GetParam(), NULL); | 1650 BoundNetLog(), GetParam(), NULL); |
| 1646 helper.RunToCompletion(&data); | 1651 helper.RunToCompletion(&data); |
| 1647 TransactionHelperResult out = helper.output(); | 1652 TransactionHelperResult out = helper.output(); |
| 1648 EXPECT_EQ(OK, out.rv); | 1653 EXPECT_EQ(OK, out.rv); |
| 1649 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1654 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1650 EXPECT_EQ("hello!", out.response_data); | 1655 EXPECT_EQ("hello!", out.response_data); |
| 1651 } | 1656 } |
| 1652 | 1657 |
| 1653 // Test that a POST with a file works. | 1658 // Test that a POST with a file works. |
| 1654 TEST_P(SpdyNetworkTransactionSpdy3Test, FilePost) { | 1659 TEST_P(SpdyNetworkTransactionSpdy3Test, FilePost) { |
| 1655 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); | 1660 scoped_ptr<SpdyFrame> req( |
| 1661 ConstructSpdyPost(kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1656 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1662 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1657 MockWrite writes[] = { | 1663 MockWrite writes[] = { |
| 1658 CreateMockWrite(*req), | 1664 CreateMockWrite(*req), |
| 1659 CreateMockWrite(*body), // POST upload frame | 1665 CreateMockWrite(*body), // POST upload frame |
| 1660 }; | 1666 }; |
| 1661 | 1667 |
| 1662 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | 1668 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| 1663 MockRead reads[] = { | 1669 MockRead reads[] = { |
| 1664 CreateMockRead(*resp), | 1670 CreateMockRead(*resp), |
| 1665 CreateMockRead(*body), | 1671 CreateMockRead(*body), |
| 1666 MockRead(ASYNC, 0, 0) // EOF | 1672 MockRead(ASYNC, 0, 0) // EOF |
| 1667 }; | 1673 }; |
| 1668 | 1674 |
| 1669 DelayedSocketData data(2, reads, arraysize(reads), | 1675 DelayedSocketData data(2, reads, arraysize(reads), |
| 1670 writes, arraysize(writes)); | 1676 writes, arraysize(writes)); |
| 1671 | 1677 |
| 1672 NormalSpdyTransactionHelper helper(CreateFilePostRequest(), | 1678 NormalSpdyTransactionHelper helper(CreateFilePostRequest(), |
| 1673 BoundNetLog(), GetParam(), NULL); | 1679 BoundNetLog(), GetParam(), NULL); |
| 1674 helper.RunToCompletion(&data); | 1680 helper.RunToCompletion(&data); |
| 1675 TransactionHelperResult out = helper.output(); | 1681 TransactionHelperResult out = helper.output(); |
| 1676 EXPECT_EQ(OK, out.rv); | 1682 EXPECT_EQ(OK, out.rv); |
| 1677 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1683 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1678 EXPECT_EQ("hello!", out.response_data); | 1684 EXPECT_EQ("hello!", out.response_data); |
| 1679 } | 1685 } |
| 1680 | 1686 |
| 1681 // Test that a complex POST works. | 1687 // Test that a complex POST works. |
| 1682 TEST_P(SpdyNetworkTransactionSpdy3Test, ComplexPost) { | 1688 TEST_P(SpdyNetworkTransactionSpdy3Test, ComplexPost) { |
| 1683 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); | 1689 scoped_ptr<SpdyFrame> req( |
| 1690 ConstructSpdyPost(kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1684 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1691 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1685 MockWrite writes[] = { | 1692 MockWrite writes[] = { |
| 1686 CreateMockWrite(*req), | 1693 CreateMockWrite(*req), |
| 1687 CreateMockWrite(*body), // POST upload frame | 1694 CreateMockWrite(*body), // POST upload frame |
| 1688 }; | 1695 }; |
| 1689 | 1696 |
| 1690 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | 1697 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| 1691 MockRead reads[] = { | 1698 MockRead reads[] = { |
| 1692 CreateMockRead(*resp), | 1699 CreateMockRead(*resp), |
| 1693 CreateMockRead(*body), | 1700 CreateMockRead(*body), |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 EXPECT_EQ(OK, out.rv); | 1801 EXPECT_EQ(OK, out.rv); |
| 1795 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1802 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1796 EXPECT_EQ(expected_response, out.response_data); | 1803 EXPECT_EQ(expected_response, out.response_data); |
| 1797 } | 1804 } |
| 1798 | 1805 |
| 1799 // Test that a POST without any post data works. | 1806 // Test that a POST without any post data works. |
| 1800 TEST_P(SpdyNetworkTransactionSpdy3Test, NullPost) { | 1807 TEST_P(SpdyNetworkTransactionSpdy3Test, NullPost) { |
| 1801 // Setup the request | 1808 // Setup the request |
| 1802 HttpRequestInfo request; | 1809 HttpRequestInfo request; |
| 1803 request.method = "POST"; | 1810 request.method = "POST"; |
| 1804 request.url = GURL("http://www.google.com/"); | 1811 request.url = GURL(kRequestUrl); |
| 1805 // Create an empty UploadData. | 1812 // Create an empty UploadData. |
| 1806 request.upload_data_stream = NULL; | 1813 request.upload_data_stream = NULL; |
| 1807 | 1814 |
| 1808 // When request.upload_data_stream is NULL for post, content-length is | 1815 // When request.upload_data_stream is NULL for post, content-length is |
| 1809 // expected to be 0. | 1816 // expected to be 0. |
| 1810 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(0, NULL, 0)); | 1817 scoped_ptr<SpdyFrame> req( |
| 1818 ConstructSpdyPost(kRequestUrl, 1, 0, LOWEST, NULL, 0)); |
| 1811 // Set the FIN bit since there will be no body. | 1819 // Set the FIN bit since there will be no body. |
| 1812 test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, kSpdyVersion3); | 1820 test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, kSpdyVersion3); |
| 1813 MockWrite writes[] = { | 1821 MockWrite writes[] = { |
| 1814 CreateMockWrite(*req), | 1822 CreateMockWrite(*req), |
| 1815 }; | 1823 }; |
| 1816 | 1824 |
| 1817 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | 1825 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| 1818 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1826 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1819 MockRead reads[] = { | 1827 MockRead reads[] = { |
| 1820 CreateMockRead(*resp), | 1828 CreateMockRead(*resp), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1840 ScopedVector<UploadElementReader> element_readers; | 1848 ScopedVector<UploadElementReader> element_readers; |
| 1841 UploadDataStream stream(&element_readers, 0); | 1849 UploadDataStream stream(&element_readers, 0); |
| 1842 | 1850 |
| 1843 // Setup the request | 1851 // Setup the request |
| 1844 HttpRequestInfo request; | 1852 HttpRequestInfo request; |
| 1845 request.method = "POST"; | 1853 request.method = "POST"; |
| 1846 request.url = GURL("http://www.google.com/"); | 1854 request.url = GURL("http://www.google.com/"); |
| 1847 request.upload_data_stream = &stream; | 1855 request.upload_data_stream = &stream; |
| 1848 | 1856 |
| 1849 const uint64 kContentLength = 0; | 1857 const uint64 kContentLength = 0; |
| 1850 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kContentLength, NULL, 0)); | 1858 scoped_ptr<SpdyFrame> req( |
| 1859 ConstructSpdyPost(kRequestUrl, 1, kContentLength, LOWEST, NULL, 0)); |
| 1851 // Set the FIN bit since there will be no body. | 1860 // Set the FIN bit since there will be no body. |
| 1852 test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, kSpdyVersion3); | 1861 test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, kSpdyVersion3); |
| 1853 MockWrite writes[] = { | 1862 MockWrite writes[] = { |
| 1854 CreateMockWrite(*req), | 1863 CreateMockWrite(*req), |
| 1855 }; | 1864 }; |
| 1856 | 1865 |
| 1857 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | 1866 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| 1858 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1867 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1859 MockRead reads[] = { | 1868 MockRead reads[] = { |
| 1860 CreateMockRead(*resp), | 1869 CreateMockRead(*resp), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1886 request.url = GURL("http://www.google.com/"); | 1895 request.url = GURL("http://www.google.com/"); |
| 1887 request.upload_data_stream = &stream; | 1896 request.upload_data_stream = &stream; |
| 1888 | 1897 |
| 1889 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); | 1898 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); |
| 1890 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); | 1899 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); |
| 1891 MockRead reads[] = { | 1900 MockRead reads[] = { |
| 1892 CreateMockRead(*stream_reply, 1), | 1901 CreateMockRead(*stream_reply, 1), |
| 1893 MockRead(ASYNC, 0, 3) // EOF | 1902 MockRead(ASYNC, 0, 3) // EOF |
| 1894 }; | 1903 }; |
| 1895 | 1904 |
| 1896 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); | 1905 scoped_ptr<SpdyFrame> req( |
| 1906 ConstructSpdyPost(kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1897 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1907 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1898 MockWrite writes[] = { | 1908 MockWrite writes[] = { |
| 1899 CreateMockWrite(*req, 0), | 1909 CreateMockWrite(*req, 0), |
| 1900 CreateMockWrite(*body, 2), | 1910 CreateMockWrite(*body, 2), |
| 1901 }; | 1911 }; |
| 1902 | 1912 |
| 1903 DeterministicSocketData data(reads, arraysize(reads), | 1913 DeterministicSocketData data(reads, arraysize(reads), |
| 1904 writes, arraysize(writes)); | 1914 writes, arraysize(writes)); |
| 1905 NormalSpdyTransactionHelper helper(CreatePostRequest(), | 1915 NormalSpdyTransactionHelper helper(CreatePostRequest(), |
| 1906 BoundNetLog(), GetParam(), NULL); | 1916 BoundNetLog(), GetParam(), NULL); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2039 // TODO(agayev): develop a socket data provider where both, reads and | 2049 // TODO(agayev): develop a socket data provider where both, reads and |
| 2040 // writes are ordered so that writing tests like these are easy and rewrite | 2050 // writes are ordered so that writing tests like these are easy and rewrite |
| 2041 // all these tests using it. Right now we are working around the | 2051 // all these tests using it. Right now we are working around the |
| 2042 // limitations as described above and it's not deterministic, tests may | 2052 // limitations as described above and it's not deterministic, tests may |
| 2043 // fail under specific circumstances. | 2053 // fail under specific circumstances. |
| 2044 TEST_P(SpdyNetworkTransactionSpdy3Test, WindowUpdateReceived) { | 2054 TEST_P(SpdyNetworkTransactionSpdy3Test, WindowUpdateReceived) { |
| 2045 static int kFrameCount = 2; | 2055 static int kFrameCount = 2; |
| 2046 scoped_ptr<std::string> content( | 2056 scoped_ptr<std::string> content( |
| 2047 new std::string(kMaxSpdyFrameChunkSize, 'a')); | 2057 new std::string(kMaxSpdyFrameChunkSize, 'a')); |
| 2048 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( | 2058 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( |
| 2049 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); | 2059 kRequestUrl, 1, kMaxSpdyFrameChunkSize * kFrameCount, LOWEST, NULL, 0)); |
| 2050 scoped_ptr<SpdyFrame> body( | 2060 scoped_ptr<SpdyFrame> body( |
| 2051 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); | 2061 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); |
| 2052 scoped_ptr<SpdyFrame> body_end( | 2062 scoped_ptr<SpdyFrame> body_end( |
| 2053 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), true)); | 2063 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), true)); |
| 2054 | 2064 |
| 2055 MockWrite writes[] = { | 2065 MockWrite writes[] = { |
| 2056 CreateMockWrite(*req, 0), | 2066 CreateMockWrite(*req, 0), |
| 2057 CreateMockWrite(*body, 1), | 2067 CreateMockWrite(*body, 1), |
| 2058 CreateMockWrite(*body_end, 2), | 2068 CreateMockWrite(*body_end, 2), |
| 2059 }; | 2069 }; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2209 | 2219 |
| 2210 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. | 2220 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. |
| 2211 TEST_P(SpdyNetworkTransactionSpdy3Test, WindowUpdateOverflow) { | 2221 TEST_P(SpdyNetworkTransactionSpdy3Test, WindowUpdateOverflow) { |
| 2212 // Number of full frames we hope to write (but will not, used to | 2222 // Number of full frames we hope to write (but will not, used to |
| 2213 // set content-length header correctly) | 2223 // set content-length header correctly) |
| 2214 static int kFrameCount = 3; | 2224 static int kFrameCount = 3; |
| 2215 | 2225 |
| 2216 scoped_ptr<std::string> content( | 2226 scoped_ptr<std::string> content( |
| 2217 new std::string(kMaxSpdyFrameChunkSize, 'a')); | 2227 new std::string(kMaxSpdyFrameChunkSize, 'a')); |
| 2218 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( | 2228 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( |
| 2219 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); | 2229 kRequestUrl, 1, kMaxSpdyFrameChunkSize * kFrameCount, LOWEST, NULL, 0)); |
| 2220 scoped_ptr<SpdyFrame> body( | 2230 scoped_ptr<SpdyFrame> body( |
| 2221 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); | 2231 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); |
| 2222 scoped_ptr<SpdyFrame> rst( | 2232 scoped_ptr<SpdyFrame> rst( |
| 2223 ConstructSpdyRstStream(1, RST_STREAM_FLOW_CONTROL_ERROR)); | 2233 ConstructSpdyRstStream(1, RST_STREAM_FLOW_CONTROL_ERROR)); |
| 2224 | 2234 |
| 2225 // We're not going to write a data frame with FIN, we'll receive a bad | 2235 // We're not going to write a data frame with FIN, we'll receive a bad |
| 2226 // WINDOW_UPDATE while sending a request and will send a RST_STREAM frame. | 2236 // WINDOW_UPDATE while sending a request and will send a RST_STREAM frame. |
| 2227 MockWrite writes[] = { | 2237 MockWrite writes[] = { |
| 2228 CreateMockWrite(*req, 0), | 2238 CreateMockWrite(*req, 0), |
| 2229 CreateMockWrite(*body, 2), | 2239 CreateMockWrite(*body, 2), |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2294 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; | 2304 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; |
| 2295 | 2305 |
| 2296 // Calculate last frame's size; 0 size data frame is legal. | 2306 // Calculate last frame's size; 0 size data frame is legal. |
| 2297 size_t last_frame_size = | 2307 size_t last_frame_size = |
| 2298 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; | 2308 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; |
| 2299 | 2309 |
| 2300 // Construct content for a data frame of maximum size. | 2310 // Construct content for a data frame of maximum size. |
| 2301 std::string content(kMaxSpdyFrameChunkSize, 'a'); | 2311 std::string content(kMaxSpdyFrameChunkSize, 'a'); |
| 2302 | 2312 |
| 2303 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( | 2313 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( |
| 2304 kSpdyStreamInitialWindowSize + kUploadDataSize, NULL, 0)); | 2314 kRequestUrl, 1, kSpdyStreamInitialWindowSize + kUploadDataSize, |
| 2315 LOWEST, NULL, 0)); |
| 2305 | 2316 |
| 2306 // Full frames. | 2317 // Full frames. |
| 2307 scoped_ptr<SpdyFrame> body1( | 2318 scoped_ptr<SpdyFrame> body1( |
| 2308 ConstructSpdyBodyFrame(1, content.c_str(), content.size(), false)); | 2319 ConstructSpdyBodyFrame(1, content.c_str(), content.size(), false)); |
| 2309 | 2320 |
| 2310 // Last frame to zero out the window size. | 2321 // Last frame to zero out the window size. |
| 2311 scoped_ptr<SpdyFrame> body2( | 2322 scoped_ptr<SpdyFrame> body2( |
| 2312 ConstructSpdyBodyFrame(1, content.c_str(), last_frame_size, false)); | 2323 ConstructSpdyBodyFrame(1, content.c_str(), last_frame_size, false)); |
| 2313 | 2324 |
| 2314 // Data frame to be sent once WINDOW_UPDATE frame is received. | 2325 // Data frame to be sent once WINDOW_UPDATE frame is received. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2390 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; | 2401 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; |
| 2391 | 2402 |
| 2392 // Calculate last frame's size; 0 size data frame is legal. | 2403 // Calculate last frame's size; 0 size data frame is legal. |
| 2393 size_t last_frame_size = | 2404 size_t last_frame_size = |
| 2394 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; | 2405 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; |
| 2395 | 2406 |
| 2396 // Construct content for a data frame of maximum size. | 2407 // Construct content for a data frame of maximum size. |
| 2397 std::string content(kMaxSpdyFrameChunkSize, 'a'); | 2408 std::string content(kMaxSpdyFrameChunkSize, 'a'); |
| 2398 | 2409 |
| 2399 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( | 2410 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( |
| 2400 kSpdyStreamInitialWindowSize + kUploadDataSize, NULL, 0)); | 2411 kRequestUrl, 1, kSpdyStreamInitialWindowSize + kUploadDataSize, |
| 2412 LOWEST, NULL, 0)); |
| 2401 | 2413 |
| 2402 // Full frames. | 2414 // Full frames. |
| 2403 scoped_ptr<SpdyFrame> body1( | 2415 scoped_ptr<SpdyFrame> body1( |
| 2404 ConstructSpdyBodyFrame(1, content.c_str(), content.size(), false)); | 2416 ConstructSpdyBodyFrame(1, content.c_str(), content.size(), false)); |
| 2405 | 2417 |
| 2406 // Last frame to zero out the window size. | 2418 // Last frame to zero out the window size. |
| 2407 scoped_ptr<SpdyFrame> body2( | 2419 scoped_ptr<SpdyFrame> body2( |
| 2408 ConstructSpdyBodyFrame(1, content.c_str(), last_frame_size, false)); | 2420 ConstructSpdyBodyFrame(1, content.c_str(), last_frame_size, false)); |
| 2409 | 2421 |
| 2410 // Data frame to be sent once SETTINGS frame is received. | 2422 // Data frame to be sent once SETTINGS frame is received. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; | 2504 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; |
| 2493 | 2505 |
| 2494 // Calculate last frame's size; 0 size data frame is legal. | 2506 // Calculate last frame's size; 0 size data frame is legal. |
| 2495 size_t last_frame_size = | 2507 size_t last_frame_size = |
| 2496 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; | 2508 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; |
| 2497 | 2509 |
| 2498 // Construct content for a data frame of maximum size. | 2510 // Construct content for a data frame of maximum size. |
| 2499 std::string content(kMaxSpdyFrameChunkSize, 'a'); | 2511 std::string content(kMaxSpdyFrameChunkSize, 'a'); |
| 2500 | 2512 |
| 2501 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( | 2513 scoped_ptr<SpdyFrame> req(ConstructSpdyPost( |
| 2502 kSpdyStreamInitialWindowSize + kUploadDataSize, NULL, 0)); | 2514 kRequestUrl, 1, kSpdyStreamInitialWindowSize + kUploadDataSize, |
| 2515 LOWEST, NULL, 0)); |
| 2503 | 2516 |
| 2504 // Full frames. | 2517 // Full frames. |
| 2505 scoped_ptr<SpdyFrame> body1( | 2518 scoped_ptr<SpdyFrame> body1( |
| 2506 ConstructSpdyBodyFrame(1, content.c_str(), content.size(), false)); | 2519 ConstructSpdyBodyFrame(1, content.c_str(), content.size(), false)); |
| 2507 | 2520 |
| 2508 // Last frame to zero out the window size. | 2521 // Last frame to zero out the window size. |
| 2509 scoped_ptr<SpdyFrame> body2( | 2522 scoped_ptr<SpdyFrame> body2( |
| 2510 ConstructSpdyBodyFrame(1, content.c_str(), last_frame_size, false)); | 2523 ConstructSpdyBodyFrame(1, content.c_str(), last_frame_size, false)); |
| 2511 | 2524 |
| 2512 // Data frame to be sent once SETTINGS frame is received. | 2525 // Data frame to be sent once SETTINGS frame is received. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2741 } | 2754 } |
| 2742 | 2755 |
| 2743 // Verify that the client can correctly deal with the user callback attempting | 2756 // Verify that the client can correctly deal with the user callback attempting |
| 2744 // to start another transaction on a session that is closing down. See | 2757 // to start another transaction on a session that is closing down. See |
| 2745 // http://crbug.com/47455 | 2758 // http://crbug.com/47455 |
| 2746 TEST_P(SpdyNetworkTransactionSpdy3Test, StartTransactionOnReadCallback) { | 2759 TEST_P(SpdyNetworkTransactionSpdy3Test, StartTransactionOnReadCallback) { |
| 2747 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2760 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 2748 MockWrite writes[] = { CreateMockWrite(*req) }; | 2761 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 2749 MockWrite writes2[] = { CreateMockWrite(*req) }; | 2762 MockWrite writes2[] = { CreateMockWrite(*req) }; |
| 2750 | 2763 |
| 2751 // The indicated length of this packet is longer than its actual length. When | 2764 // The indicated length of this frame is longer than its actual length. When |
| 2752 // the session receives an empty packet after this one, it shuts down the | 2765 // the session receives an empty frame after this one, it shuts down the |
| 2753 // session, and calls the read callback with the incomplete data. | 2766 // session, and calls the read callback with the incomplete data. |
| 2754 const uint8 kGetBodyFrame2[] = { | 2767 const uint8 kGetBodyFrame2[] = { |
| 2755 0x00, 0x00, 0x00, 0x01, | 2768 0x00, 0x00, 0x00, 0x01, |
| 2756 0x01, 0x00, 0x00, 0x07, | 2769 0x01, 0x00, 0x00, 0x07, |
| 2757 'h', 'e', 'l', 'l', 'o', '!', | 2770 'h', 'e', 'l', 'l', 'o', '!', |
| 2758 }; | 2771 }; |
| 2759 | 2772 |
| 2760 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2773 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2761 MockRead reads[] = { | 2774 MockRead reads[] = { |
| 2762 CreateMockRead(*resp, 2), | 2775 CreateMockRead(*resp, 2), |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2880 "http", | 2893 "http", |
| 2881 ":path", | 2894 ":path", |
| 2882 "/index.php", | 2895 "/index.php", |
| 2883 "user-agent", | 2896 "user-agent", |
| 2884 "", | 2897 "", |
| 2885 ":version", | 2898 ":version", |
| 2886 "HTTP/1.1" | 2899 "HTTP/1.1" |
| 2887 }; | 2900 }; |
| 2888 | 2901 |
| 2889 // Setup writes/reads to www.google.com | 2902 // Setup writes/reads to www.google.com |
| 2890 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket( | 2903 scoped_ptr<SpdyFrame> req(ConstructSpdyFrame( |
| 2891 kSynStartHeader, kExtraHeaders, arraysize(kExtraHeaders) / 2, | 2904 kSynStartHeader, kExtraHeaders, arraysize(kExtraHeaders) / 2, |
| 2892 kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); | 2905 kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); |
| 2893 scoped_ptr<SpdyFrame> req2(ConstructSpdyPacket( | 2906 scoped_ptr<SpdyFrame> req2(ConstructSpdyFrame( |
| 2894 kSynStartHeader, kExtraHeaders, arraysize(kExtraHeaders) / 2, | 2907 kSynStartHeader, kExtraHeaders, arraysize(kExtraHeaders) / 2, |
| 2895 kStandardGetHeaders2, arraysize(kStandardGetHeaders2) / 2)); | 2908 kStandardGetHeaders2, arraysize(kStandardGetHeaders2) / 2)); |
| 2896 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReplyRedirect(1)); | 2909 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReplyRedirect(1)); |
| 2897 MockWrite writes[] = { | 2910 MockWrite writes[] = { |
| 2898 CreateMockWrite(*req, 1), | 2911 CreateMockWrite(*req, 1), |
| 2899 }; | 2912 }; |
| 2900 MockRead reads[] = { | 2913 MockRead reads[] = { |
| 2901 CreateMockRead(*resp, 2), | 2914 CreateMockRead(*resp, 2), |
| 2902 MockRead(ASYNC, 0, 0, 3) // EOF | 2915 MockRead(ASYNC, 0, 0, 3) // EOF |
| 2903 }; | 2916 }; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3095 ":path", | 3108 ":path", |
| 3096 "/", | 3109 "/", |
| 3097 "user-agent", | 3110 "user-agent", |
| 3098 "", | 3111 "", |
| 3099 ":version", | 3112 ":version", |
| 3100 "HTTP/1.1" | 3113 "HTTP/1.1" |
| 3101 }; | 3114 }; |
| 3102 | 3115 |
| 3103 // Setup writes/reads to www.google.com | 3116 // Setup writes/reads to www.google.com |
| 3104 scoped_ptr<SpdyFrame> req( | 3117 scoped_ptr<SpdyFrame> req( |
| 3105 ConstructSpdyPacket(kSynStartHeader, | 3118 ConstructSpdyFrame(kSynStartHeader, |
| 3106 kExtraHeaders, | 3119 kExtraHeaders, |
| 3107 arraysize(kExtraHeaders) / 2, | 3120 arraysize(kExtraHeaders) / 2, |
| 3108 kStandardGetHeaders, | 3121 kStandardGetHeaders, |
| 3109 arraysize(kStandardGetHeaders) / 2)); | 3122 arraysize(kStandardGetHeaders) / 2)); |
| 3110 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 3123 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3111 scoped_ptr<SpdyFrame> rep( | 3124 scoped_ptr<SpdyFrame> rep( |
| 3112 ConstructSpdyPush(NULL, | 3125 ConstructSpdyPush(NULL, |
| 3113 0, | 3126 0, |
| 3114 2, | 3127 2, |
| 3115 1, | 3128 1, |
| 3116 "http://www.google.com/foo.dat", | 3129 "http://www.google.com/foo.dat", |
| 3117 "301 Moved Permanently", | 3130 "301 Moved Permanently", |
| 3118 "http://www.foo.com/index.php")); | 3131 "http://www.foo.com/index.php")); |
| 3119 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 3132 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3139 ":scheme", | 3152 ":scheme", |
| 3140 "http", | 3153 "http", |
| 3141 ":path", | 3154 ":path", |
| 3142 "/index.php", | 3155 "/index.php", |
| 3143 "user-agent", | 3156 "user-agent", |
| 3144 "", | 3157 "", |
| 3145 ":version", | 3158 ":version", |
| 3146 "HTTP/1.1" | 3159 "HTTP/1.1" |
| 3147 }; | 3160 }; |
| 3148 scoped_ptr<SpdyFrame> req2( | 3161 scoped_ptr<SpdyFrame> req2( |
| 3149 ConstructSpdyPacket(kSynStartHeader, | 3162 ConstructSpdyFrame(kSynStartHeader, |
| 3150 kExtraHeaders, | 3163 kExtraHeaders, |
| 3151 arraysize(kExtraHeaders) / 2, | 3164 arraysize(kExtraHeaders) / 2, |
| 3152 kStandardGetHeaders2, | 3165 kStandardGetHeaders2, |
| 3153 arraysize(kStandardGetHeaders2) / 2)); | 3166 arraysize(kStandardGetHeaders2) / 2)); |
| 3154 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 1)); | 3167 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3155 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(1, true)); | 3168 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(1, true)); |
| 3156 MockWrite writes2[] = { | 3169 MockWrite writes2[] = { |
| 3157 CreateMockWrite(*req2, 1), | 3170 CreateMockWrite(*req2, 1), |
| 3158 }; | 3171 }; |
| 3159 MockRead reads2[] = { | 3172 MockRead reads2[] = { |
| 3160 CreateMockRead(*resp2, 2), | 3173 CreateMockRead(*resp2, 2), |
| 3161 CreateMockRead(*body2, 3), | 3174 CreateMockRead(*body2, 3), |
| 3162 MockRead(ASYNC, 0, 0, 5) // EOF | 3175 MockRead(ASYNC, 0, 0, 5) // EOF |
| 3163 }; | 3176 }; |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3958 ConstructSpdyGet(test_cases[i].extra_headers[0], | 3971 ConstructSpdyGet(test_cases[i].extra_headers[0], |
| 3959 test_cases[i].num_headers[0], | 3972 test_cases[i].num_headers[0], |
| 3960 false, 1, LOWEST)); | 3973 false, 1, LOWEST)); |
| 3961 | 3974 |
| 3962 MockWrite writes[] = { | 3975 MockWrite writes[] = { |
| 3963 CreateMockWrite(*frame_req), | 3976 CreateMockWrite(*frame_req), |
| 3964 }; | 3977 }; |
| 3965 | 3978 |
| 3966 // Construct the reply. | 3979 // Construct the reply. |
| 3967 scoped_ptr<SpdyFrame> frame_reply( | 3980 scoped_ptr<SpdyFrame> frame_reply( |
| 3968 ConstructSpdyPacket(*test_cases[i].syn_reply, | 3981 ConstructSpdyFrame(*test_cases[i].syn_reply, |
| 3969 test_cases[i].extra_headers[1], | 3982 test_cases[i].extra_headers[1], |
| 3970 test_cases[i].num_headers[1], | 3983 test_cases[i].num_headers[1], |
| 3971 NULL, | 3984 NULL, |
| 3972 0)); | 3985 0)); |
| 3973 | 3986 |
| 3974 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 3987 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 3975 MockRead reads[] = { | 3988 MockRead reads[] = { |
| 3976 CreateMockRead(*frame_reply), | 3989 CreateMockRead(*frame_reply), |
| 3977 CreateMockRead(*body), | 3990 CreateMockRead(*body), |
| 3978 MockRead(ASYNC, 0, 0) // EOF | 3991 MockRead(ASYNC, 0, 0) // EOF |
| 3979 }; | 3992 }; |
| 3980 | 3993 |
| 3981 // Attach the headers to the request. | 3994 // Attach the headers to the request. |
| 3982 int header_count = test_cases[i].num_headers[0]; | 3995 int header_count = test_cases[i].num_headers[0]; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4075 }; | 4088 }; |
| 4076 | 4089 |
| 4077 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 4090 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 4078 scoped_ptr<SpdyFrame> req( | 4091 scoped_ptr<SpdyFrame> req( |
| 4079 ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4092 ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 4080 MockWrite writes[] = { | 4093 MockWrite writes[] = { |
| 4081 CreateMockWrite(*req), | 4094 CreateMockWrite(*req), |
| 4082 }; | 4095 }; |
| 4083 | 4096 |
| 4084 scoped_ptr<SpdyFrame> resp( | 4097 scoped_ptr<SpdyFrame> resp( |
| 4085 ConstructSpdyPacket(kSynStartHeader, | 4098 ConstructSpdyFrame(kSynStartHeader, |
| 4086 NULL, 0, | 4099 NULL, 0, |
| 4087 test_cases[i].headers, | 4100 test_cases[i].headers, |
| 4088 test_cases[i].num_headers)); | 4101 test_cases[i].num_headers)); |
| 4089 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 4102 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 4090 MockRead reads[] = { | 4103 MockRead reads[] = { |
| 4091 CreateMockRead(*resp), | 4104 CreateMockRead(*resp), |
| 4092 CreateMockRead(*body), | 4105 CreateMockRead(*body), |
| 4093 MockRead(ASYNC, 0, 0) // EOF | 4106 MockRead(ASYNC, 0, 0) // EOF |
| 4094 }; | 4107 }; |
| 4095 | 4108 |
| 4096 DelayedSocketData data(1, reads, arraysize(reads), | 4109 DelayedSocketData data(1, reads, arraysize(reads), |
| 4097 writes, arraysize(writes)); | 4110 writes, arraysize(writes)); |
| 4098 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 4111 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4777 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4790 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4778 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4791 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4779 host_port_pair).empty()); | 4792 host_port_pair).empty()); |
| 4780 | 4793 |
| 4781 // Construct the request. | 4794 // Construct the request. |
| 4782 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4795 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 4783 MockWrite writes[] = { CreateMockWrite(*req) }; | 4796 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4784 | 4797 |
| 4785 // Construct the reply. | 4798 // Construct the reply. |
| 4786 scoped_ptr<SpdyFrame> reply( | 4799 scoped_ptr<SpdyFrame> reply( |
| 4787 ConstructSpdyPacket(kSynReplyInfo, | 4800 ConstructSpdyFrame(kSynReplyInfo, |
| 4788 kExtraHeaders, | 4801 kExtraHeaders, |
| 4789 arraysize(kExtraHeaders) / 2, | 4802 arraysize(kExtraHeaders) / 2, |
| 4790 NULL, | 4803 NULL, |
| 4791 0)); | 4804 0)); |
| 4792 | 4805 |
| 4793 const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH; | 4806 const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH; |
| 4794 unsigned int kSampleValue1 = 0x0a0a0a0a; | 4807 unsigned int kSampleValue1 = 0x0a0a0a0a; |
| 4795 const SpdySettingsIds kSampleId2 = SETTINGS_DOWNLOAD_BANDWIDTH; | 4808 const SpdySettingsIds kSampleId2 = SETTINGS_DOWNLOAD_BANDWIDTH; |
| 4796 unsigned int kSampleValue2 = 0x0b0b0b0b; | 4809 unsigned int kSampleValue2 = 0x0b0b0b0b; |
| 4797 const SpdySettingsIds kSampleId3 = SETTINGS_ROUND_TRIP_TIME; | 4810 const SpdySettingsIds kSampleId3 = SETTINGS_ROUND_TRIP_TIME; |
| 4798 unsigned int kSampleValue3 = 0x0c0c0c0c; | 4811 unsigned int kSampleValue3 = 0x0c0c0c0c; |
| 4799 scoped_ptr<SpdyFrame> settings_frame; | 4812 scoped_ptr<SpdyFrame> settings_frame; |
| 4800 { | 4813 { |
| 4801 // Construct the SETTINGS frame. | 4814 // Construct the SETTINGS frame. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4916 // Construct the request. | 4929 // Construct the request. |
| 4917 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4930 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 4918 | 4931 |
| 4919 MockWrite writes[] = { | 4932 MockWrite writes[] = { |
| 4920 CreateMockWrite(*settings_frame), | 4933 CreateMockWrite(*settings_frame), |
| 4921 CreateMockWrite(*req), | 4934 CreateMockWrite(*req), |
| 4922 }; | 4935 }; |
| 4923 | 4936 |
| 4924 // Construct the reply. | 4937 // Construct the reply. |
| 4925 scoped_ptr<SpdyFrame> reply( | 4938 scoped_ptr<SpdyFrame> reply( |
| 4926 ConstructSpdyPacket(kSynReplyInfo, | 4939 ConstructSpdyFrame(kSynReplyInfo, |
| 4927 kExtraHeaders, | 4940 kExtraHeaders, |
| 4928 arraysize(kExtraHeaders) / 2, | 4941 arraysize(kExtraHeaders) / 2, |
| 4929 NULL, | 4942 NULL, |
| 4930 0)); | 4943 0)); |
| 4931 | 4944 |
| 4932 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 4945 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 4933 MockRead reads[] = { | 4946 MockRead reads[] = { |
| 4934 CreateMockRead(*reply), | 4947 CreateMockRead(*reply), |
| 4935 CreateMockRead(*body), | 4948 CreateMockRead(*body), |
| 4936 MockRead(ASYNC, 0, 0) // EOF | 4949 MockRead(ASYNC, 0, 0) // EOF |
| 4937 }; | 4950 }; |
| 4938 | 4951 |
| 4939 DelayedSocketData data(2, reads, arraysize(reads), | 4952 DelayedSocketData data(2, reads, arraysize(reads), |
| 4940 writes, arraysize(writes)); | 4953 writes, arraysize(writes)); |
| (...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6439 // And now we can allow everything else to run to completion. | 6452 // And now we can allow everything else to run to completion. |
| 6440 data.SetStop(10); | 6453 data.SetStop(10); |
| 6441 data.Run(); | 6454 data.Run(); |
| 6442 EXPECT_EQ(OK, callback2.WaitForResult()); | 6455 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 6443 EXPECT_EQ(OK, callback3.WaitForResult()); | 6456 EXPECT_EQ(OK, callback3.WaitForResult()); |
| 6444 | 6457 |
| 6445 helper.VerifyDataConsumed(); | 6458 helper.VerifyDataConsumed(); |
| 6446 } | 6459 } |
| 6447 | 6460 |
| 6448 } // namespace net | 6461 } // namespace net |
| OLD | NEW |