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/quic/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 | 1361 |
1362 request_.url = GURL(promise_url_); | 1362 request_.url = GURL(promise_url_); |
1363 | 1363 |
1364 // Make the second stream that will exercise the first step of the | 1364 // Make the second stream that will exercise the first step of the |
1365 // server push rendezvous mechanism. | 1365 // server push rendezvous mechanism. |
1366 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1366 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1367 net_log_.bound(), | 1367 net_log_.bound(), |
1368 callback_.callback())); | 1368 callback_.callback())); |
1369 | 1369 |
1370 // Receive the promised response headers. | 1370 // Receive the promised response headers. |
1371 response_headers_ = promised_response_; | 1371 response_headers_ = promised_response_.Clone(); |
1372 size_t spdy_response_headers_frame_length; | 1372 size_t spdy_response_headers_frame_length; |
1373 ProcessPacket(InnerConstructResponseHeadersPacket( | 1373 ProcessPacket(InnerConstructResponseHeadersPacket( |
1374 1, promise_id_, false, &spdy_response_headers_frame_length)); | 1374 1, promise_id_, false, &spdy_response_headers_frame_length)); |
1375 | 1375 |
1376 // Receive the promised response body. | 1376 // Receive the promised response body. |
1377 const char kResponseBody[] = "Hello world!"; | 1377 const char kResponseBody[] = "Hello world!"; |
1378 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, | 1378 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, |
1379 kResponseBody, &server_maker_)); | 1379 kResponseBody, &server_maker_)); |
1380 | 1380 |
1381 // Now sending a matching request will have successful rendezvous | 1381 // Now sending a matching request will have successful rendezvous |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1431 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1432 net_log_.bound(), | 1432 net_log_.bound(), |
1433 callback_.callback())); | 1433 callback_.callback())); |
1434 | 1434 |
1435 // Now sending a matching request will rendezvous with the promised | 1435 // Now sending a matching request will rendezvous with the promised |
1436 // stream, but pending secondary validation. | 1436 // stream, but pending secondary validation. |
1437 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( | 1437 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( |
1438 headers_, &response_, callback_.callback())); | 1438 headers_, &response_, callback_.callback())); |
1439 | 1439 |
1440 // Receive the promised response headers. | 1440 // Receive the promised response headers. |
1441 response_headers_ = promised_response_; | 1441 response_headers_ = promised_response_.Clone(); |
1442 size_t spdy_response_headers_frame_length; | 1442 size_t spdy_response_headers_frame_length; |
1443 ProcessPacket(InnerConstructResponseHeadersPacket( | 1443 ProcessPacket(InnerConstructResponseHeadersPacket( |
1444 1, promise_id_, false, &spdy_response_headers_frame_length)); | 1444 1, promise_id_, false, &spdy_response_headers_frame_length)); |
1445 | 1445 |
1446 // Receive the promised response body. | 1446 // Receive the promised response body. |
1447 const char kResponseBody[] = "Hello world!"; | 1447 const char kResponseBody[] = "Hello world!"; |
1448 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, | 1448 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, |
1449 kResponseBody, &server_maker_)); | 1449 kResponseBody, &server_maker_)); |
1450 | 1450 |
1451 base::RunLoop().RunUntilIdle(); | 1451 base::RunLoop().RunUntilIdle(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 | 1504 |
1505 request_.url = GURL(promise_url_); | 1505 request_.url = GURL(promise_url_); |
1506 | 1506 |
1507 // Make the second stream that will exercise the first step of the | 1507 // Make the second stream that will exercise the first step of the |
1508 // server push rendezvous mechanism. | 1508 // server push rendezvous mechanism. |
1509 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1509 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1510 net_log_.bound(), | 1510 net_log_.bound(), |
1511 callback_.callback())); | 1511 callback_.callback())); |
1512 | 1512 |
1513 // Receive the promised response headers. | 1513 // Receive the promised response headers. |
1514 response_headers_ = promised_response_; | 1514 response_headers_ = promised_response_.Clone(); |
1515 size_t spdy_response_headers_frame_length; | 1515 size_t spdy_response_headers_frame_length; |
1516 ProcessPacket(InnerConstructResponseHeadersPacket( | 1516 ProcessPacket(InnerConstructResponseHeadersPacket( |
1517 1, promise_id_, false, &spdy_response_headers_frame_length)); | 1517 1, promise_id_, false, &spdy_response_headers_frame_length)); |
1518 | 1518 |
1519 // Receive the promised response body. | 1519 // Receive the promised response body. |
1520 const char kResponseBody[] = "Hello world!"; | 1520 const char kResponseBody[] = "Hello world!"; |
1521 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, | 1521 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, |
1522 kResponseBody, &server_maker_)); | 1522 kResponseBody, &server_maker_)); |
1523 | 1523 |
1524 // Now sending a matching request will have successful rendezvous | 1524 // Now sending a matching request will have successful rendezvous |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 | 1606 |
1607 headers_.SetHeader("accept-encoding", "gzip"); | 1607 headers_.SetHeader("accept-encoding", "gzip"); |
1608 | 1608 |
1609 // Now sending a matching request will rendezvous with the promised | 1609 // Now sending a matching request will rendezvous with the promised |
1610 // stream, but pending secondary validation. | 1610 // stream, but pending secondary validation. |
1611 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( | 1611 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( |
1612 headers_, &response_, callback_.callback())); | 1612 headers_, &response_, callback_.callback())); |
1613 | 1613 |
1614 // Receive the promised response headers. | 1614 // Receive the promised response headers. |
1615 promised_response_["vary"] = "accept-encoding"; | 1615 promised_response_["vary"] = "accept-encoding"; |
1616 response_headers_ = promised_response_; | 1616 response_headers_ = promised_response_.Clone(); |
1617 size_t spdy_response_headers_frame_length; | 1617 size_t spdy_response_headers_frame_length; |
1618 ProcessPacket(InnerConstructResponseHeadersPacket( | 1618 ProcessPacket(InnerConstructResponseHeadersPacket( |
1619 1, promise_id_, false, &spdy_response_headers_frame_length)); | 1619 1, promise_id_, false, &spdy_response_headers_frame_length)); |
1620 | 1620 |
1621 // Receive the promised response body. | 1621 // Receive the promised response body. |
1622 const char kResponseBody[] = "Hello world!"; | 1622 const char kResponseBody[] = "Hello world!"; |
1623 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, | 1623 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, |
1624 kResponseBody, &server_maker_)); | 1624 kResponseBody, &server_maker_)); |
1625 | 1625 |
1626 base::RunLoop().RunUntilIdle(); | 1626 base::RunLoop().RunUntilIdle(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 | 1696 |
1697 headers_.SetHeader("accept-encoding", "sdch"); | 1697 headers_.SetHeader("accept-encoding", "sdch"); |
1698 | 1698 |
1699 // Now sending a matching request will rendezvous with the promised | 1699 // Now sending a matching request will rendezvous with the promised |
1700 // stream, but pending secondary validation. | 1700 // stream, but pending secondary validation. |
1701 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( | 1701 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( |
1702 headers_, &response_, callback_.callback())); | 1702 headers_, &response_, callback_.callback())); |
1703 | 1703 |
1704 // Receive the promised response headers. | 1704 // Receive the promised response headers. |
1705 promised_response_["vary"] = "accept-encoding"; | 1705 promised_response_["vary"] = "accept-encoding"; |
1706 response_headers_ = promised_response_; | 1706 response_headers_ = promised_response_.Clone(); |
1707 size_t spdy_response_headers_frame_length; | 1707 size_t spdy_response_headers_frame_length; |
1708 ProcessPacket(InnerConstructResponseHeadersPacket( | 1708 ProcessPacket(InnerConstructResponseHeadersPacket( |
1709 1, promise_id_, false, &spdy_response_headers_frame_length)); | 1709 1, promise_id_, false, &spdy_response_headers_frame_length)); |
1710 | 1710 |
1711 base::RunLoop().RunUntilIdle(); | 1711 base::RunLoop().RunUntilIdle(); |
1712 | 1712 |
1713 // Rendezvous should have failed due to vary mismatch, so the | 1713 // Rendezvous should have failed due to vary mismatch, so the |
1714 // promised stream should have been aborted, and instead we have a | 1714 // promised stream should have been aborted, and instead we have a |
1715 // new, regular client initiated stream. | 1715 // new, regular client initiated stream. |
1716 EXPECT_EQ(OK, callback_.WaitForResult()); | 1716 EXPECT_EQ(OK, callback_.WaitForResult()); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1832 EXPECT_TRUE(AtEof()); | 1832 EXPECT_TRUE(AtEof()); |
1833 | 1833 |
1834 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. | 1834 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. |
1835 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), | 1835 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), |
1836 stream_->GetTotalSentBytes()); | 1836 stream_->GetTotalSentBytes()); |
1837 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | 1837 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
1838 } | 1838 } |
1839 | 1839 |
1840 } // namespace test | 1840 } // namespace test |
1841 } // namespace net | 1841 } // namespace net |
OLD | NEW |