| 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 <cmath> | 5 #include <cmath> |
| 6 #include <memory> | 6 #include <memory> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 helper.VerifyDataConsumed(); | 1665 helper.VerifyDataConsumed(); |
| 1666 } | 1666 } |
| 1667 | 1667 |
| 1668 // Test that a simple PUT request works. | 1668 // Test that a simple PUT request works. |
| 1669 TEST_P(SpdyNetworkTransactionTest, Put) { | 1669 TEST_P(SpdyNetworkTransactionTest, Put) { |
| 1670 // Setup the request | 1670 // Setup the request |
| 1671 HttpRequestInfo request; | 1671 HttpRequestInfo request; |
| 1672 request.method = "PUT"; | 1672 request.method = "PUT"; |
| 1673 request.url = GURL(GetDefaultUrl()); | 1673 request.url = GURL(GetDefaultUrl()); |
| 1674 | 1674 |
| 1675 std::unique_ptr<SpdyHeaderBlock> put_headers( | 1675 SpdyHeaderBlock put_headers( |
| 1676 spdy_util_.ConstructPutHeaderBlock(GetDefaultUrl(), 0)); | 1676 spdy_util_.ConstructPutHeaderBlock(GetDefaultUrl(), 0)); |
| 1677 std::unique_ptr<SpdySerializedFrame> req( | 1677 std::unique_ptr<SpdySerializedFrame> req( |
| 1678 spdy_util_.ConstructSpdySyn(1, *put_headers, LOWEST, true)); | 1678 spdy_util_.ConstructSpdySyn(1, std::move(put_headers), LOWEST, true)); |
| 1679 MockWrite writes[] = { | 1679 MockWrite writes[] = { |
| 1680 CreateMockWrite(*req, 0), | 1680 CreateMockWrite(*req, 0), |
| 1681 }; | 1681 }; |
| 1682 | 1682 |
| 1683 std::unique_ptr<SpdySerializedFrame> resp( | 1683 std::unique_ptr<SpdySerializedFrame> resp( |
| 1684 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1684 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1685 std::unique_ptr<SpdySerializedFrame> body( | 1685 std::unique_ptr<SpdySerializedFrame> body( |
| 1686 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1686 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1687 MockRead reads[] = { | 1687 MockRead reads[] = { |
| 1688 CreateMockRead(*resp, 1), | 1688 CreateMockRead(*resp, 1), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1700 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1700 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 // Test that a simple HEAD request works. | 1703 // Test that a simple HEAD request works. |
| 1704 TEST_P(SpdyNetworkTransactionTest, Head) { | 1704 TEST_P(SpdyNetworkTransactionTest, Head) { |
| 1705 // Setup the request | 1705 // Setup the request |
| 1706 HttpRequestInfo request; | 1706 HttpRequestInfo request; |
| 1707 request.method = "HEAD"; | 1707 request.method = "HEAD"; |
| 1708 request.url = GURL(GetDefaultUrl()); | 1708 request.url = GURL(GetDefaultUrl()); |
| 1709 | 1709 |
| 1710 std::unique_ptr<SpdyHeaderBlock> head_headers( | 1710 SpdyHeaderBlock head_headers( |
| 1711 spdy_util_.ConstructHeadHeaderBlock(GetDefaultUrl(), 0)); | 1711 spdy_util_.ConstructHeadHeaderBlock(GetDefaultUrl(), 0)); |
| 1712 std::unique_ptr<SpdySerializedFrame> req( | 1712 std::unique_ptr<SpdySerializedFrame> req( |
| 1713 spdy_util_.ConstructSpdySyn(1, *head_headers, LOWEST, true)); | 1713 spdy_util_.ConstructSpdySyn(1, std::move(head_headers), LOWEST, true)); |
| 1714 MockWrite writes[] = { | 1714 MockWrite writes[] = { |
| 1715 CreateMockWrite(*req, 0), | 1715 CreateMockWrite(*req, 0), |
| 1716 }; | 1716 }; |
| 1717 | 1717 |
| 1718 std::unique_ptr<SpdySerializedFrame> resp( | 1718 std::unique_ptr<SpdySerializedFrame> resp( |
| 1719 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1719 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1720 std::unique_ptr<SpdySerializedFrame> body( | 1720 std::unique_ptr<SpdySerializedFrame> body( |
| 1721 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1721 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1722 MockRead reads[] = { | 1722 MockRead reads[] = { |
| 1723 CreateMockRead(*resp, 1), | 1723 CreateMockRead(*resp, 1), |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 BufferedSpdyFramer framer(spdy_util_.spdy_version()); | 1940 BufferedSpdyFramer framer(spdy_util_.spdy_version()); |
| 1941 // Setup the request | 1941 // Setup the request |
| 1942 HttpRequestInfo request; | 1942 HttpRequestInfo request; |
| 1943 request.method = "POST"; | 1943 request.method = "POST"; |
| 1944 request.url = GURL(GetDefaultUrl()); | 1944 request.url = GURL(GetDefaultUrl()); |
| 1945 // Create an empty UploadData. | 1945 // Create an empty UploadData. |
| 1946 request.upload_data_stream = NULL; | 1946 request.upload_data_stream = NULL; |
| 1947 | 1947 |
| 1948 // When request.upload_data_stream is NULL for post, content-length is | 1948 // When request.upload_data_stream is NULL for post, content-length is |
| 1949 // expected to be 0. | 1949 // expected to be 0. |
| 1950 std::unique_ptr<SpdyHeaderBlock> req_block( | 1950 SpdyHeaderBlock req_block( |
| 1951 spdy_util_.ConstructPostHeaderBlock(GetDefaultUrl(), 0)); | 1951 spdy_util_.ConstructPostHeaderBlock(GetDefaultUrl(), 0)); |
| 1952 std::unique_ptr<SpdySerializedFrame> req( | 1952 std::unique_ptr<SpdySerializedFrame> req( |
| 1953 spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, true)); | 1953 spdy_util_.ConstructSpdySyn(1, std::move(req_block), LOWEST, true)); |
| 1954 | 1954 |
| 1955 MockWrite writes[] = { | 1955 MockWrite writes[] = { |
| 1956 CreateMockWrite(*req, 0), | 1956 CreateMockWrite(*req, 0), |
| 1957 }; | 1957 }; |
| 1958 | 1958 |
| 1959 std::unique_ptr<SpdySerializedFrame> resp( | 1959 std::unique_ptr<SpdySerializedFrame> resp( |
| 1960 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 1960 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 1961 std::unique_ptr<SpdySerializedFrame> body( | 1961 std::unique_ptr<SpdySerializedFrame> body( |
| 1962 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1962 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1963 MockRead reads[] = { | 1963 MockRead reads[] = { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1985 ElementsUploadDataStream stream(std::move(element_readers), 0); | 1985 ElementsUploadDataStream stream(std::move(element_readers), 0); |
| 1986 | 1986 |
| 1987 // Setup the request | 1987 // Setup the request |
| 1988 HttpRequestInfo request; | 1988 HttpRequestInfo request; |
| 1989 request.method = "POST"; | 1989 request.method = "POST"; |
| 1990 request.url = GURL(GetDefaultUrl()); | 1990 request.url = GURL(GetDefaultUrl()); |
| 1991 request.upload_data_stream = &stream; | 1991 request.upload_data_stream = &stream; |
| 1992 | 1992 |
| 1993 const uint64_t kContentLength = 0; | 1993 const uint64_t kContentLength = 0; |
| 1994 | 1994 |
| 1995 std::unique_ptr<SpdyHeaderBlock> req_block( | 1995 SpdyHeaderBlock req_block( |
| 1996 spdy_util_.ConstructPostHeaderBlock(GetDefaultUrl(), kContentLength)); | 1996 spdy_util_.ConstructPostHeaderBlock(GetDefaultUrl(), kContentLength)); |
| 1997 std::unique_ptr<SpdySerializedFrame> req( | 1997 std::unique_ptr<SpdySerializedFrame> req( |
| 1998 spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, true)); | 1998 spdy_util_.ConstructSpdySyn(1, std::move(req_block), LOWEST, true)); |
| 1999 | 1999 |
| 2000 MockWrite writes[] = { | 2000 MockWrite writes[] = { |
| 2001 CreateMockWrite(*req, 0), | 2001 CreateMockWrite(*req, 0), |
| 2002 }; | 2002 }; |
| 2003 | 2003 |
| 2004 std::unique_ptr<SpdySerializedFrame> resp( | 2004 std::unique_ptr<SpdySerializedFrame> resp( |
| 2005 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 2005 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 2006 std::unique_ptr<SpdySerializedFrame> body( | 2006 std::unique_ptr<SpdySerializedFrame> body( |
| 2007 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2007 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 2008 MockRead reads[] = { | 2008 MockRead reads[] = { |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2442 ASSERT_EQ(ERR_IO_PENDING, rv); | 2442 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 2443 data.Resume(); | 2443 data.Resume(); |
| 2444 | 2444 |
| 2445 // Finish running rest of tasks. | 2445 // Finish running rest of tasks. |
| 2446 base::RunLoop().RunUntilIdle(); | 2446 base::RunLoop().RunUntilIdle(); |
| 2447 helper.VerifyDataConsumed(); | 2447 helper.VerifyDataConsumed(); |
| 2448 } | 2448 } |
| 2449 | 2449 |
| 2450 // Send a spdy request to www.example.org that gets redirected to www.foo.com. | 2450 // Send a spdy request to www.example.org that gets redirected to www.foo.com. |
| 2451 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectGetRequest) { | 2451 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectGetRequest) { |
| 2452 std::unique_ptr<SpdyHeaderBlock> headers( | 2452 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); |
| 2453 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); | 2453 headers["user-agent"] = ""; |
| 2454 (*headers)["user-agent"] = ""; | 2454 headers["accept-encoding"] = "gzip, deflate"; |
| 2455 (*headers)["accept-encoding"] = "gzip, deflate"; | |
| 2456 std::unique_ptr<SpdyHeaderBlock> headers2( | |
| 2457 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); | |
| 2458 (*headers2)["user-agent"] = ""; | |
| 2459 (*headers2)["accept-encoding"] = "gzip, deflate"; | |
| 2460 | 2455 |
| 2461 // Setup writes/reads to www.example.org | 2456 // Setup writes/reads to www.example.org |
| 2462 std::unique_ptr<SpdySerializedFrame> req( | 2457 std::unique_ptr<SpdySerializedFrame> req( |
| 2463 spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, true)); | 2458 spdy_util_.ConstructSpdySyn(1, std::move(headers), LOWEST, true)); |
| 2464 std::unique_ptr<SpdySerializedFrame> req2( | |
| 2465 spdy_util_.ConstructSpdySyn(1, *headers2, LOWEST, true)); | |
| 2466 std::unique_ptr<SpdySerializedFrame> resp( | 2459 std::unique_ptr<SpdySerializedFrame> resp( |
| 2467 spdy_util_.ConstructSpdyGetSynReplyRedirect(1)); | 2460 spdy_util_.ConstructSpdyGetSynReplyRedirect(1)); |
| 2468 MockWrite writes[] = { | 2461 MockWrite writes[] = { |
| 2469 CreateMockWrite(*req, 1), | 2462 CreateMockWrite(*req, 1), |
| 2470 }; | 2463 }; |
| 2471 MockRead reads[] = { | 2464 MockRead reads[] = { |
| 2472 CreateMockRead(*resp, 2), | 2465 CreateMockRead(*resp, 2), |
| 2473 MockRead(ASYNC, 0, 0, 3) // EOF | 2466 MockRead(ASYNC, 0, 0, 3) // EOF |
| 2474 }; | 2467 }; |
| 2468 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2475 | 2469 |
| 2476 // Setup writes/reads to www.foo.com | 2470 // Setup writes/reads to www.foo.com |
| 2471 SpdyHeaderBlock headers2( |
| 2472 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); |
| 2473 headers2["user-agent"] = ""; |
| 2474 headers2["accept-encoding"] = "gzip, deflate"; |
| 2475 std::unique_ptr<SpdySerializedFrame> req2( |
| 2476 spdy_util_.ConstructSpdySyn(1, std::move(headers2), LOWEST, true)); |
| 2477 MockWrite writes2[] = { |
| 2478 CreateMockWrite(*req2, 1), |
| 2479 }; |
| 2480 |
| 2477 std::unique_ptr<SpdySerializedFrame> resp2( | 2481 std::unique_ptr<SpdySerializedFrame> resp2( |
| 2478 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2482 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2479 std::unique_ptr<SpdySerializedFrame> body2( | 2483 std::unique_ptr<SpdySerializedFrame> body2( |
| 2480 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2484 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 2481 MockWrite writes2[] = { | |
| 2482 CreateMockWrite(*req2, 1), | |
| 2483 }; | |
| 2484 MockRead reads2[] = { | 2485 MockRead reads2[] = { |
| 2485 CreateMockRead(*resp2, 2), | 2486 CreateMockRead(*resp2, 2), |
| 2486 CreateMockRead(*body2, 3), | 2487 CreateMockRead(*body2, 3), |
| 2487 MockRead(ASYNC, 0, 0, 4) // EOF | 2488 MockRead(ASYNC, 0, 0, 4) // EOF |
| 2488 }; | 2489 }; |
| 2489 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2490 |
| 2490 SequencedSocketData data2(reads2, arraysize(reads2), writes2, | 2491 SequencedSocketData data2(reads2, arraysize(reads2), writes2, |
| 2491 arraysize(writes2)); | 2492 arraysize(writes2)); |
| 2492 | 2493 |
| 2493 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN | 2494 // TODO(erikchen): Make test support SPDYSSL, SPDYNPN |
| 2494 TestDelegate d; | 2495 TestDelegate d; |
| 2495 { | 2496 { |
| 2496 SpdyURLRequestContext spdy_url_request_context(GetParam().protocol); | 2497 SpdyURLRequestContext spdy_url_request_context(GetParam().protocol); |
| 2497 std::unique_ptr<URLRequest> r(spdy_url_request_context.CreateRequest( | 2498 std::unique_ptr<URLRequest> r(spdy_url_request_context.CreateRequest( |
| 2498 GURL(GetDefaultUrl()), DEFAULT_PRIORITY, &d)); | 2499 GURL(GetDefaultUrl()), DEFAULT_PRIORITY, &d)); |
| 2499 spdy_url_request_context.socket_factory(). | 2500 spdy_url_request_context.socket_factory(). |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2517 } | 2518 } |
| 2518 EXPECT_TRUE(data.AllReadDataConsumed()); | 2519 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2519 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2520 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2520 EXPECT_TRUE(data2.AllReadDataConsumed()); | 2521 EXPECT_TRUE(data2.AllReadDataConsumed()); |
| 2521 EXPECT_TRUE(data2.AllWriteDataConsumed()); | 2522 EXPECT_TRUE(data2.AllWriteDataConsumed()); |
| 2522 } | 2523 } |
| 2523 | 2524 |
| 2524 // Send a spdy request to www.example.org. Get a pushed stream that redirects to | 2525 // Send a spdy request to www.example.org. Get a pushed stream that redirects to |
| 2525 // www.foo.com. | 2526 // www.foo.com. |
| 2526 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) { | 2527 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) { |
| 2527 std::unique_ptr<SpdyHeaderBlock> headers( | 2528 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); |
| 2528 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); | 2529 headers["user-agent"] = ""; |
| 2529 (*headers)["user-agent"] = ""; | 2530 headers["accept-encoding"] = "gzip, deflate"; |
| 2530 (*headers)["accept-encoding"] = "gzip, deflate"; | |
| 2531 | 2531 |
| 2532 // Setup writes/reads to www.example.org | 2532 // Setup writes/reads to www.example.org |
| 2533 std::unique_ptr<SpdySerializedFrame> req( | 2533 std::unique_ptr<SpdySerializedFrame> req( |
| 2534 spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, true)); | 2534 spdy_util_.ConstructSpdySyn(1, std::move(headers), LOWEST, true)); |
| 2535 std::unique_ptr<SpdySerializedFrame> resp( | 2535 std::unique_ptr<SpdySerializedFrame> resp( |
| 2536 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2536 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2537 std::unique_ptr<SpdySerializedFrame> rep(spdy_util_.ConstructSpdyPush( | 2537 std::unique_ptr<SpdySerializedFrame> rep(spdy_util_.ConstructSpdyPush( |
| 2538 NULL, 0, 2, 1, GetDefaultUrlWithPath("/foo.dat").c_str(), | 2538 NULL, 0, 2, 1, GetDefaultUrlWithPath("/foo.dat").c_str(), |
| 2539 "301 Moved Permanently", "http://www.foo.com/index.php")); | 2539 "301 Moved Permanently", "http://www.foo.com/index.php")); |
| 2540 std::unique_ptr<SpdySerializedFrame> body( | 2540 std::unique_ptr<SpdySerializedFrame> body( |
| 2541 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2541 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 2542 std::unique_ptr<SpdySerializedFrame> rst( | 2542 std::unique_ptr<SpdySerializedFrame> rst( |
| 2543 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_CANCEL)); | 2543 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_CANCEL)); |
| 2544 MockWrite writes[] = { | 2544 MockWrite writes[] = { |
| 2545 CreateMockWrite(*req, 1), | 2545 CreateMockWrite(*req, 1), |
| 2546 CreateMockWrite(*rst, 6), | 2546 CreateMockWrite(*rst, 6), |
| 2547 }; | 2547 }; |
| 2548 MockRead reads[] = { | 2548 MockRead reads[] = { |
| 2549 CreateMockRead(*resp, 2), | 2549 CreateMockRead(*resp, 2), |
| 2550 CreateMockRead(*rep, 3), | 2550 CreateMockRead(*rep, 3), |
| 2551 CreateMockRead(*body, 4), | 2551 CreateMockRead(*body, 4), |
| 2552 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause | 2552 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause |
| 2553 MockRead(ASYNC, 0, 0, 7) // EOF | 2553 MockRead(ASYNC, 0, 0, 7) // EOF |
| 2554 }; | 2554 }; |
| 2555 | 2555 |
| 2556 // Setup writes/reads to www.foo.com | 2556 // Setup writes/reads to www.foo.com |
| 2557 std::unique_ptr<SpdyHeaderBlock> headers2( | 2557 SpdyHeaderBlock headers2( |
| 2558 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); | 2558 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); |
| 2559 (*headers2)["user-agent"] = ""; | 2559 headers2["user-agent"] = ""; |
| 2560 (*headers2)["accept-encoding"] = "gzip, deflate"; | 2560 headers2["accept-encoding"] = "gzip, deflate"; |
| 2561 std::unique_ptr<SpdySerializedFrame> req2( | 2561 std::unique_ptr<SpdySerializedFrame> req2( |
| 2562 spdy_util_.ConstructSpdySyn(1, *headers2, LOWEST, true)); | 2562 spdy_util_.ConstructSpdySyn(1, std::move(headers2), LOWEST, true)); |
| 2563 std::unique_ptr<SpdySerializedFrame> resp2( | 2563 std::unique_ptr<SpdySerializedFrame> resp2( |
| 2564 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2564 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2565 std::unique_ptr<SpdySerializedFrame> body2( | 2565 std::unique_ptr<SpdySerializedFrame> body2( |
| 2566 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2566 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 2567 MockWrite writes2[] = { | 2567 MockWrite writes2[] = { |
| 2568 CreateMockWrite(*req2, 1), | 2568 CreateMockWrite(*req2, 1), |
| 2569 }; | 2569 }; |
| 2570 MockRead reads2[] = { | 2570 MockRead reads2[] = { |
| 2571 CreateMockRead(*resp2, 2), | 2571 CreateMockRead(*resp2, 2), |
| 2572 CreateMockRead(*body2, 3), | 2572 CreateMockRead(*body2, 3), |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3057 std::unique_ptr<SpdySerializedFrame> stream1_body( | 3057 std::unique_ptr<SpdySerializedFrame> stream1_body( |
| 3058 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3058 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3059 std::unique_ptr<SpdySerializedFrame> stream2_rst( | 3059 std::unique_ptr<SpdySerializedFrame> stream2_rst( |
| 3060 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); | 3060 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); |
| 3061 MockWrite writes[] = { | 3061 MockWrite writes[] = { |
| 3062 CreateMockWrite(*stream1_syn, 0), CreateMockWrite(*stream2_rst, 3), | 3062 CreateMockWrite(*stream1_syn, 0), CreateMockWrite(*stream2_rst, 3), |
| 3063 }; | 3063 }; |
| 3064 | 3064 |
| 3065 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 3065 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 3066 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3066 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3067 std::unique_ptr<SpdyHeaderBlock> incomplete_headers(new SpdyHeaderBlock()); | 3067 SpdyHeaderBlock incomplete_headers; |
| 3068 (*incomplete_headers)[spdy_util_.GetStatusKey()] = "200 OK"; | 3068 incomplete_headers[spdy_util_.GetStatusKey()] = "200 OK"; |
| 3069 (*incomplete_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 3069 incomplete_headers[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
| 3070 (*incomplete_headers)["hello"] = "bye"; | 3070 incomplete_headers["hello"] = "bye"; |
| 3071 std::unique_ptr<SpdySerializedFrame> stream2_syn( | 3071 std::unique_ptr<SpdySerializedFrame> stream2_syn( |
| 3072 spdy_util_.ConstructInitialSpdyPushFrame(std::move(incomplete_headers), 2, | 3072 spdy_util_.ConstructInitialSpdyPushFrame(std::move(incomplete_headers), 2, |
| 3073 1)); | 3073 1)); |
| 3074 MockRead reads[] = { | 3074 MockRead reads[] = { |
| 3075 CreateMockRead(*stream1_reply, 1), | 3075 CreateMockRead(*stream1_reply, 1), |
| 3076 CreateMockRead(*stream2_syn, 2), | 3076 CreateMockRead(*stream2_syn, 2), |
| 3077 CreateMockRead(*stream1_body, 4), | 3077 CreateMockRead(*stream1_body, 4), |
| 3078 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5) // Force a pause | 3078 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5) // Force a pause |
| 3079 }; | 3079 }; |
| 3080 | 3080 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3390 | 3390 |
| 3391 MockWrite writes[] = { | 3391 MockWrite writes[] = { |
| 3392 CreateMockWrite(*frame_req, 0), | 3392 CreateMockWrite(*frame_req, 0), |
| 3393 }; | 3393 }; |
| 3394 | 3394 |
| 3395 // Construct the reply. | 3395 // Construct the reply. |
| 3396 SpdyHeaderBlock reply_headers; | 3396 SpdyHeaderBlock reply_headers; |
| 3397 AppendToHeaderBlock(test_cases[i].extra_headers[1], | 3397 AppendToHeaderBlock(test_cases[i].extra_headers[1], |
| 3398 test_cases[i].num_headers[1], | 3398 test_cases[i].num_headers[1], |
| 3399 &reply_headers); | 3399 &reply_headers); |
| 3400 // Construct the expected header reply string before moving |reply_headers|. |
| 3401 std::string expected_reply = |
| 3402 spdy_test_util.ConstructSpdyReplyString(reply_headers); |
| 3403 |
| 3400 std::unique_ptr<SpdySerializedFrame> frame_reply( | 3404 std::unique_ptr<SpdySerializedFrame> frame_reply( |
| 3401 spdy_test_util.ConstructSpdyReply(1, reply_headers)); | 3405 spdy_test_util.ConstructSpdyReply(1, std::move(reply_headers))); |
| 3402 | 3406 |
| 3403 std::unique_ptr<SpdySerializedFrame> body( | 3407 std::unique_ptr<SpdySerializedFrame> body( |
| 3404 spdy_test_util.ConstructSpdyBodyFrame(1, true)); | 3408 spdy_test_util.ConstructSpdyBodyFrame(1, true)); |
| 3405 MockRead reads[] = { | 3409 MockRead reads[] = { |
| 3406 CreateMockRead(*frame_reply, 1), | 3410 CreateMockRead(*frame_reply, 1), |
| 3407 CreateMockRead(*body, 2), | 3411 CreateMockRead(*body, 2), |
| 3408 MockRead(ASYNC, 0, 3) // EOF | 3412 MockRead(ASYNC, 0, 3) // EOF |
| 3409 }; | 3413 }; |
| 3410 | 3414 |
| 3411 // Attach the headers to the request. | 3415 // Attach the headers to the request. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3438 ASSERT_TRUE(headers) << i; | 3442 ASSERT_TRUE(headers) << i; |
| 3439 size_t iter = 0; | 3443 size_t iter = 0; |
| 3440 std::string name, value, lines; | 3444 std::string name, value, lines; |
| 3441 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { | 3445 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { |
| 3442 lines.append(name); | 3446 lines.append(name); |
| 3443 lines.append(": "); | 3447 lines.append(": "); |
| 3444 lines.append(value); | 3448 lines.append(value); |
| 3445 lines.append("\n"); | 3449 lines.append("\n"); |
| 3446 } | 3450 } |
| 3447 | 3451 |
| 3448 // Construct the expected header reply string. | |
| 3449 std::string expected_reply = | |
| 3450 spdy_test_util.ConstructSpdyReplyString(reply_headers); | |
| 3451 EXPECT_EQ(expected_reply, lines) << i; | 3452 EXPECT_EQ(expected_reply, lines) << i; |
| 3452 } | 3453 } |
| 3453 } | 3454 } |
| 3454 | 3455 |
| 3455 // Verify that we don't crash on invalid SynReply responses. | 3456 // Verify that we don't crash on invalid SynReply responses. |
| 3456 TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { | 3457 TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { |
| 3457 struct InvalidSynReplyTests { | 3458 struct InvalidSynReplyTests { |
| 3458 int num_headers; | 3459 int num_headers; |
| 3459 const char* headers[10]; | 3460 const char* headers[10]; |
| 3460 } test_cases[] = { | 3461 } test_cases[] = { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3485 spdy_test_util.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 3486 spdy_test_util.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 3486 MockWrite writes[] = { | 3487 MockWrite writes[] = { |
| 3487 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 2), | 3488 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 2), |
| 3488 }; | 3489 }; |
| 3489 | 3490 |
| 3490 // Construct the reply. | 3491 // Construct the reply. |
| 3491 SpdyHeaderBlock reply_headers; | 3492 SpdyHeaderBlock reply_headers; |
| 3492 AppendToHeaderBlock( | 3493 AppendToHeaderBlock( |
| 3493 test_cases[i].headers, test_cases[i].num_headers, &reply_headers); | 3494 test_cases[i].headers, test_cases[i].num_headers, &reply_headers); |
| 3494 std::unique_ptr<SpdySerializedFrame> resp( | 3495 std::unique_ptr<SpdySerializedFrame> resp( |
| 3495 spdy_test_util.ConstructSpdyReply(1, reply_headers)); | 3496 spdy_test_util.ConstructSpdyReply(1, std::move(reply_headers))); |
| 3496 MockRead reads[] = { | 3497 MockRead reads[] = { |
| 3497 CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 3) // EOF | 3498 CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 3) // EOF |
| 3498 }; | 3499 }; |
| 3499 | 3500 |
| 3500 SequencedSocketData data(reads, arraysize(reads), writes, | 3501 SequencedSocketData data(reads, arraysize(reads), writes, |
| 3501 arraysize(writes)); | 3502 arraysize(writes)); |
| 3502 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3503 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3503 BoundNetLog(), GetParam(), NULL); | 3504 BoundNetLog(), GetParam(), NULL); |
| 3504 helper.RunToCompletion(&data); | 3505 helper.RunToCompletion(&data); |
| 3505 TransactionHelperResult out = helper.output(); | 3506 TransactionHelperResult out = helper.output(); |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4245 EXPECT_TRUE(spdy_session_pool->http_server_properties() | 4246 EXPECT_TRUE(spdy_session_pool->http_server_properties() |
| 4246 ->GetSpdySettings(spdy_server) | 4247 ->GetSpdySettings(spdy_server) |
| 4247 .empty()); | 4248 .empty()); |
| 4248 | 4249 |
| 4249 // Construct the request. | 4250 // Construct the request. |
| 4250 std::unique_ptr<SpdySerializedFrame> req( | 4251 std::unique_ptr<SpdySerializedFrame> req( |
| 4251 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4252 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 4252 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 4253 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
| 4253 | 4254 |
| 4254 // Construct the reply. | 4255 // Construct the reply. |
| 4255 std::unique_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); | 4256 SpdyHeaderBlock reply_headers; |
| 4256 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; | 4257 reply_headers[spdy_util_.GetStatusKey()] = "200"; |
| 4257 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 4258 reply_headers[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
| 4258 std::unique_ptr<SpdySerializedFrame> reply( | 4259 std::unique_ptr<SpdySerializedFrame> reply( |
| 4259 spdy_util_.ConstructSpdyFrame(kSynReplyInfo, std::move(reply_headers))); | 4260 spdy_util_.ConstructSpdyFrame(kSynReplyInfo, std::move(reply_headers))); |
| 4260 | 4261 |
| 4261 const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH; | 4262 const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH; |
| 4262 unsigned int kSampleValue1 = 0x0a0a0a0a; | 4263 unsigned int kSampleValue1 = 0x0a0a0a0a; |
| 4263 const SpdySettingsIds kSampleId2 = SETTINGS_DOWNLOAD_BANDWIDTH; | 4264 const SpdySettingsIds kSampleId2 = SETTINGS_DOWNLOAD_BANDWIDTH; |
| 4264 unsigned int kSampleValue2 = 0x0b0b0b0b; | 4265 unsigned int kSampleValue2 = 0x0b0b0b0b; |
| 4265 const SpdySettingsIds kSampleId3 = SETTINGS_ROUND_TRIP_TIME; | 4266 const SpdySettingsIds kSampleId3 = SETTINGS_ROUND_TRIP_TIME; |
| 4266 unsigned int kSampleValue3 = 0x0c0c0c0c; | 4267 unsigned int kSampleValue3 = 0x0c0c0c0c; |
| 4267 std::unique_ptr<SpdySerializedFrame> settings_frame; | 4268 std::unique_ptr<SpdySerializedFrame> settings_frame; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4393 std::unique_ptr<SpdySerializedFrame> req( | 4394 std::unique_ptr<SpdySerializedFrame> req( |
| 4394 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4395 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 4395 | 4396 |
| 4396 MockWrite writes[] = { | 4397 MockWrite writes[] = { |
| 4397 CreateMockWrite(*initial_settings_frame, 0), | 4398 CreateMockWrite(*initial_settings_frame, 0), |
| 4398 CreateMockWrite(*settings_frame, 1), | 4399 CreateMockWrite(*settings_frame, 1), |
| 4399 CreateMockWrite(*req, 2), | 4400 CreateMockWrite(*req, 2), |
| 4400 }; | 4401 }; |
| 4401 | 4402 |
| 4402 // Construct the reply. | 4403 // Construct the reply. |
| 4403 std::unique_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); | 4404 SpdyHeaderBlock reply_headers; |
| 4404 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; | 4405 reply_headers[spdy_util_.GetStatusKey()] = "200"; |
| 4405 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 4406 reply_headers[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
| 4406 std::unique_ptr<SpdySerializedFrame> reply( | 4407 std::unique_ptr<SpdySerializedFrame> reply( |
| 4407 spdy_util_.ConstructSpdyFrame(kSynReplyInfo, std::move(reply_headers))); | 4408 spdy_util_.ConstructSpdyFrame(kSynReplyInfo, std::move(reply_headers))); |
| 4408 | 4409 |
| 4409 std::unique_ptr<SpdySerializedFrame> body( | 4410 std::unique_ptr<SpdySerializedFrame> body( |
| 4410 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4411 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 4411 MockRead reads[] = { | 4412 MockRead reads[] = { |
| 4412 CreateMockRead(*reply, 3), | 4413 CreateMockRead(*reply, 3), |
| 4413 CreateMockRead(*body, 4), | 4414 CreateMockRead(*body, 4), |
| 4414 MockRead(ASYNC, 0, 5) // EOF | 4415 MockRead(ASYNC, 0, 5) // EOF |
| 4415 }; | 4416 }; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4540 request.method = "GET"; | 4541 request.method = "GET"; |
| 4541 request.url = GURL("https://www.example.org/"); | 4542 request.url = GURL("https://www.example.org/"); |
| 4542 std::unique_ptr<SpdySessionDependencies> session_deps( | 4543 std::unique_ptr<SpdySessionDependencies> session_deps( |
| 4543 CreateSpdySessionDependencies(GetParam())); | 4544 CreateSpdySessionDependencies(GetParam())); |
| 4544 // Do not force SPDY so that second socket can negotiate HTTP/1.1. | 4545 // Do not force SPDY so that second socket can negotiate HTTP/1.1. |
| 4545 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 4546 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), |
| 4546 GetParam(), std::move(session_deps)); | 4547 GetParam(), std::move(session_deps)); |
| 4547 | 4548 |
| 4548 // First socket: HTTP/2 request rejected with HTTP_1_1_REQUIRED. | 4549 // First socket: HTTP/2 request rejected with HTTP_1_1_REQUIRED. |
| 4549 const char* url = request.url.spec().c_str(); | 4550 const char* url = request.url.spec().c_str(); |
| 4550 std::unique_ptr<SpdyHeaderBlock> headers( | 4551 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(url)); |
| 4551 spdy_util_.ConstructGetHeaderBlock(url)); | |
| 4552 std::unique_ptr<SpdySerializedFrame> req( | 4552 std::unique_ptr<SpdySerializedFrame> req( |
| 4553 spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, true)); | 4553 spdy_util_.ConstructSpdySyn(1, std::move(headers), LOWEST, true)); |
| 4554 MockWrite writes0[] = {CreateMockWrite(*req, 0)}; | 4554 MockWrite writes0[] = {CreateMockWrite(*req, 0)}; |
| 4555 std::unique_ptr<SpdySerializedFrame> go_away(spdy_util_.ConstructSpdyGoAway( | 4555 std::unique_ptr<SpdySerializedFrame> go_away(spdy_util_.ConstructSpdyGoAway( |
| 4556 0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please.")); | 4556 0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please.")); |
| 4557 MockRead reads0[] = {CreateMockRead(*go_away, 1)}; | 4557 MockRead reads0[] = {CreateMockRead(*go_away, 1)}; |
| 4558 SequencedSocketData data0(reads0, arraysize(reads0), writes0, | 4558 SequencedSocketData data0(reads0, arraysize(reads0), writes0, |
| 4559 arraysize(writes0)); | 4559 arraysize(writes0)); |
| 4560 | 4560 |
| 4561 std::unique_ptr<SSLSocketDataProvider> ssl_provider0( | 4561 std::unique_ptr<SSLSocketDataProvider> ssl_provider0( |
| 4562 new SSLSocketDataProvider(ASYNC, OK)); | 4562 new SSLSocketDataProvider(ASYNC, OK)); |
| 4563 // Expect HTTP/2 protocols too in SSLConfig. | 4563 // Expect HTTP/2 protocols too in SSLConfig. |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5162 TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) { | 5162 TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) { |
| 5163 std::unique_ptr<SpdySerializedFrame> stream1_syn( | 5163 std::unique_ptr<SpdySerializedFrame> stream1_syn( |
| 5164 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 5164 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 5165 MockWrite writes[] = { | 5165 MockWrite writes[] = { |
| 5166 CreateMockWrite(*stream1_syn, 0), | 5166 CreateMockWrite(*stream1_syn, 0), |
| 5167 }; | 5167 }; |
| 5168 | 5168 |
| 5169 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 5169 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 5170 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 5170 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); |
| 5171 | 5171 |
| 5172 std::unique_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 5172 SpdyHeaderBlock initial_headers; |
| 5173 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/foo.dat"), | 5173 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/foo.dat"), |
| 5174 initial_headers.get()); | 5174 &initial_headers); |
| 5175 std::unique_ptr<SpdySerializedFrame> stream2_syn( | 5175 std::unique_ptr<SpdySerializedFrame> stream2_syn( |
| 5176 spdy_util_.ConstructInitialSpdyPushFrame(std::move(initial_headers), 2, | 5176 spdy_util_.ConstructInitialSpdyPushFrame(std::move(initial_headers), 2, |
| 5177 1)); | 5177 1)); |
| 5178 | 5178 |
| 5179 SpdyHeaderBlock late_headers; | 5179 SpdyHeaderBlock late_headers; |
| 5180 late_headers[spdy_util_.GetStatusKey()] = "200"; | 5180 late_headers[spdy_util_.GetStatusKey()] = "200"; |
| 5181 late_headers[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 5181 late_headers[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
| 5182 late_headers["hello"] = "bye"; | 5182 late_headers["hello"] = "bye"; |
| 5183 std::unique_ptr<SpdySerializedFrame> stream2_headers( | 5183 std::unique_ptr<SpdySerializedFrame> stream2_headers( |
| 5184 spdy_util_.ConstructSpdyResponseHeaders(2, late_headers, false)); | 5184 spdy_util_.ConstructSpdyResponseHeaders(2, std::move(late_headers), |
| 5185 false)); |
| 5185 | 5186 |
| 5186 std::unique_ptr<SpdySerializedFrame> stream1_body( | 5187 std::unique_ptr<SpdySerializedFrame> stream1_body( |
| 5187 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5188 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5188 | 5189 |
| 5189 const char kPushedData[] = "pushed"; | 5190 const char kPushedData[] = "pushed"; |
| 5190 std::unique_ptr<SpdySerializedFrame> stream2_body( | 5191 std::unique_ptr<SpdySerializedFrame> stream2_body( |
| 5191 spdy_util_.ConstructSpdyBodyFrame(2, kPushedData, strlen(kPushedData), | 5192 spdy_util_.ConstructSpdyBodyFrame(2, kPushedData, strlen(kPushedData), |
| 5192 true)); | 5193 true)); |
| 5193 | 5194 |
| 5194 MockRead reads[] = { | 5195 MockRead reads[] = { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5221 TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) { | 5222 TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) { |
| 5222 // We push a stream and attempt to claim it before the headers come down. | 5223 // We push a stream and attempt to claim it before the headers come down. |
| 5223 std::unique_ptr<SpdySerializedFrame> stream1_syn( | 5224 std::unique_ptr<SpdySerializedFrame> stream1_syn( |
| 5224 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 5225 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 5225 MockWrite writes[] = { | 5226 MockWrite writes[] = { |
| 5226 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5227 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
| 5227 }; | 5228 }; |
| 5228 | 5229 |
| 5229 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 5230 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 5230 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 5231 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); |
| 5231 std::unique_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 5232 SpdyHeaderBlock initial_headers; |
| 5232 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/foo.dat"), | 5233 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/foo.dat"), |
| 5233 initial_headers.get()); | 5234 &initial_headers); |
| 5234 std::unique_ptr<SpdySerializedFrame> stream2_syn( | 5235 std::unique_ptr<SpdySerializedFrame> stream2_syn( |
| 5235 spdy_util_.ConstructInitialSpdyPushFrame(std::move(initial_headers), 2, | 5236 spdy_util_.ConstructInitialSpdyPushFrame(std::move(initial_headers), 2, |
| 5236 1)); | 5237 1)); |
| 5237 std::unique_ptr<SpdySerializedFrame> stream1_body( | 5238 std::unique_ptr<SpdySerializedFrame> stream1_body( |
| 5238 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5239 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5239 SpdyHeaderBlock late_headers; | 5240 SpdyHeaderBlock late_headers; |
| 5240 late_headers[spdy_util_.GetStatusKey()] = "200"; | 5241 late_headers[spdy_util_.GetStatusKey()] = "200"; |
| 5241 late_headers[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 5242 late_headers[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
| 5242 late_headers["hello"] = "bye"; | 5243 late_headers["hello"] = "bye"; |
| 5243 std::unique_ptr<SpdySerializedFrame> stream2_headers( | 5244 std::unique_ptr<SpdySerializedFrame> stream2_headers( |
| 5244 spdy_util_.ConstructSpdyResponseHeaders(2, late_headers, false)); | 5245 spdy_util_.ConstructSpdyResponseHeaders(2, std::move(late_headers), |
| 5246 false)); |
| 5245 const char kPushedData[] = "pushed"; | 5247 const char kPushedData[] = "pushed"; |
| 5246 std::unique_ptr<SpdySerializedFrame> stream2_body( | 5248 std::unique_ptr<SpdySerializedFrame> stream2_body( |
| 5247 spdy_util_.ConstructSpdyBodyFrame(2, kPushedData, strlen(kPushedData), | 5249 spdy_util_.ConstructSpdyBodyFrame(2, kPushedData, strlen(kPushedData), |
| 5248 true)); | 5250 true)); |
| 5249 MockRead reads[] = { | 5251 MockRead reads[] = { |
| 5250 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream2_syn, 2), | 5252 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream2_syn, 2), |
| 5251 CreateMockRead(*stream1_body, 3), MockRead(ASYNC, ERR_IO_PENDING, 4), | 5253 CreateMockRead(*stream1_body, 3), MockRead(ASYNC, ERR_IO_PENDING, 4), |
| 5252 CreateMockRead(*stream2_headers, 5), CreateMockRead(*stream2_body, 6), | 5254 CreateMockRead(*stream2_headers, 5), CreateMockRead(*stream2_body, 6), |
| 5253 MockRead(ASYNC, ERR_IO_PENDING, 7), MockRead(ASYNC, 0, 8), // EOF | 5255 MockRead(ASYNC, ERR_IO_PENDING, 7), MockRead(ASYNC, 0, 8), // EOF |
| 5254 }; | 5256 }; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5330 // We push a stream and attempt to claim it before the headers come down. | 5332 // We push a stream and attempt to claim it before the headers come down. |
| 5331 std::unique_ptr<SpdySerializedFrame> stream1_syn( | 5333 std::unique_ptr<SpdySerializedFrame> stream1_syn( |
| 5332 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 5334 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 5333 MockWrite writes[] = { | 5335 MockWrite writes[] = { |
| 5334 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5336 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
| 5335 }; | 5337 }; |
| 5336 | 5338 |
| 5337 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 5339 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 5338 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 5340 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); |
| 5339 | 5341 |
| 5340 std::unique_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 5342 SpdyHeaderBlock initial_headers; |
| 5341 if (spdy_util_.spdy_version() < HTTP2) { | 5343 if (spdy_util_.spdy_version() < HTTP2) { |
| 5342 // In HTTP/2 PUSH_PROMISE headers won't show up in the response headers. | 5344 // In HTTP/2 PUSH_PROMISE headers won't show up in the response headers. |
| 5343 (*initial_headers)["alpha"] = "beta"; | 5345 initial_headers["alpha"] = "beta"; |
| 5344 } | 5346 } |
| 5345 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/foo.dat"), | 5347 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/foo.dat"), |
| 5346 initial_headers.get()); | 5348 &initial_headers); |
| 5347 std::unique_ptr<SpdySerializedFrame> stream2_syn( | 5349 std::unique_ptr<SpdySerializedFrame> stream2_syn( |
| 5348 spdy_util_.ConstructInitialSpdyPushFrame(std::move(initial_headers), 2, | 5350 spdy_util_.ConstructInitialSpdyPushFrame(std::move(initial_headers), 2, |
| 5349 1)); | 5351 1)); |
| 5350 | 5352 |
| 5351 std::unique_ptr<SpdySerializedFrame> stream1_body( | 5353 std::unique_ptr<SpdySerializedFrame> stream1_body( |
| 5352 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5354 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5353 | 5355 |
| 5354 SpdyHeaderBlock middle_headers; | 5356 SpdyHeaderBlock middle_headers; |
| 5355 middle_headers["hello"] = "bye"; | 5357 middle_headers["hello"] = "bye"; |
| 5356 std::unique_ptr<SpdySerializedFrame> stream2_headers1( | 5358 std::unique_ptr<SpdySerializedFrame> stream2_headers1( |
| 5357 spdy_util_.ConstructSpdyResponseHeaders(2, middle_headers, false)); | 5359 spdy_util_.ConstructSpdyResponseHeaders(2, std::move(middle_headers), |
| 5360 false)); |
| 5358 | 5361 |
| 5359 SpdyHeaderBlock late_headers; | 5362 SpdyHeaderBlock late_headers; |
| 5360 late_headers[spdy_util_.GetStatusKey()] = "200"; | 5363 late_headers[spdy_util_.GetStatusKey()] = "200"; |
| 5361 if (spdy_util_.spdy_version() < HTTP2) { | 5364 if (spdy_util_.spdy_version() < HTTP2) { |
| 5362 // HTTP/2 eliminates use of the :version header. | 5365 // HTTP/2 eliminates use of the :version header. |
| 5363 late_headers[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 5366 late_headers[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
| 5364 } | 5367 } |
| 5365 std::unique_ptr<SpdySerializedFrame> stream2_headers2( | 5368 std::unique_ptr<SpdySerializedFrame> stream2_headers2( |
| 5366 spdy_util_.ConstructSpdyResponseHeaders(2, late_headers, false)); | 5369 spdy_util_.ConstructSpdyResponseHeaders(2, std::move(late_headers), |
| 5370 false)); |
| 5367 | 5371 |
| 5368 const char kPushedData[] = "pushed"; | 5372 const char kPushedData[] = "pushed"; |
| 5369 std::unique_ptr<SpdySerializedFrame> stream2_body( | 5373 std::unique_ptr<SpdySerializedFrame> stream2_body( |
| 5370 spdy_util_.ConstructSpdyBodyFrame(2, kPushedData, strlen(kPushedData), | 5374 spdy_util_.ConstructSpdyBodyFrame(2, kPushedData, strlen(kPushedData), |
| 5371 true)); | 5375 true)); |
| 5372 | 5376 |
| 5373 MockRead reads[] = { | 5377 MockRead reads[] = { |
| 5374 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream2_syn, 2), | 5378 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream2_syn, 2), |
| 5375 CreateMockRead(*stream1_body, 3), MockRead(ASYNC, ERR_IO_PENDING, 4), | 5379 CreateMockRead(*stream1_body, 3), MockRead(ASYNC, ERR_IO_PENDING, 4), |
| 5376 CreateMockRead(*stream2_headers1, 5), | 5380 CreateMockRead(*stream2_headers1, 5), |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5462 // We push a stream and attempt to claim it before the headers come down. | 5466 // We push a stream and attempt to claim it before the headers come down. |
| 5463 std::unique_ptr<SpdySerializedFrame> stream1_syn( | 5467 std::unique_ptr<SpdySerializedFrame> stream1_syn( |
| 5464 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 5468 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 5465 MockWrite writes[] = { | 5469 MockWrite writes[] = { |
| 5466 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5470 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
| 5467 }; | 5471 }; |
| 5468 | 5472 |
| 5469 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 5473 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 5470 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 5474 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); |
| 5471 | 5475 |
| 5472 std::unique_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 5476 SpdyHeaderBlock initial_headers; |
| 5473 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/foo.dat"), | 5477 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/foo.dat"), |
| 5474 initial_headers.get()); | 5478 &initial_headers); |
| 5475 std::unique_ptr<SpdySerializedFrame> stream2_syn( | 5479 std::unique_ptr<SpdySerializedFrame> stream2_syn( |
| 5476 spdy_util_.ConstructInitialSpdyPushFrame(std::move(initial_headers), 2, | 5480 spdy_util_.ConstructInitialSpdyPushFrame(std::move(initial_headers), 2, |
| 5477 1)); | 5481 1)); |
| 5478 | 5482 |
| 5479 std::unique_ptr<SpdySerializedFrame> stream1_body( | 5483 std::unique_ptr<SpdySerializedFrame> stream1_body( |
| 5480 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5484 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5481 | 5485 |
| 5482 SpdyHeaderBlock middle_headers; | 5486 SpdyHeaderBlock middle_headers; |
| 5483 middle_headers["hello"] = "bye"; | 5487 middle_headers["hello"] = "bye"; |
| 5484 std::unique_ptr<SpdySerializedFrame> stream2_headers1( | 5488 std::unique_ptr<SpdySerializedFrame> stream2_headers1( |
| 5485 spdy_util_.ConstructSpdyResponseHeaders(2, middle_headers, false)); | 5489 spdy_util_.ConstructSpdyResponseHeaders(2, std::move(middle_headers), |
| 5490 false)); |
| 5486 | 5491 |
| 5487 const char kPushedData[] = "pushed"; | 5492 const char kPushedData[] = "pushed"; |
| 5488 std::unique_ptr<SpdySerializedFrame> stream2_body( | 5493 std::unique_ptr<SpdySerializedFrame> stream2_body( |
| 5489 spdy_util_.ConstructSpdyBodyFrame(2, kPushedData, strlen(kPushedData), | 5494 spdy_util_.ConstructSpdyBodyFrame(2, kPushedData, strlen(kPushedData), |
| 5490 true)); | 5495 true)); |
| 5491 | 5496 |
| 5492 MockRead reads[] = { | 5497 MockRead reads[] = { |
| 5493 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream2_syn, 2), | 5498 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream2_syn, 2), |
| 5494 CreateMockRead(*stream1_body, 3), MockRead(ASYNC, ERR_IO_PENDING, 4), | 5499 CreateMockRead(*stream1_body, 3), MockRead(ASYNC, ERR_IO_PENDING, 4), |
| 5495 CreateMockRead(*stream2_headers1, 5), CreateMockRead(*stream2_body, 6), | 5500 CreateMockRead(*stream2_headers1, 5), CreateMockRead(*stream2_body, 6), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5565 MockWrite writes[] = { | 5570 MockWrite writes[] = { |
| 5566 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4), | 5571 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4), |
| 5567 }; | 5572 }; |
| 5568 | 5573 |
| 5569 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 5574 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 5570 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5575 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5571 | 5576 |
| 5572 SpdyHeaderBlock late_headers; | 5577 SpdyHeaderBlock late_headers; |
| 5573 late_headers["hello"] = "bye"; | 5578 late_headers["hello"] = "bye"; |
| 5574 std::unique_ptr<SpdySerializedFrame> stream1_headers( | 5579 std::unique_ptr<SpdySerializedFrame> stream1_headers( |
| 5575 spdy_util_.ConstructSpdyResponseHeaders(1, late_headers, false)); | 5580 spdy_util_.ConstructSpdyResponseHeaders(1, std::move(late_headers), |
| 5581 false)); |
| 5576 std::unique_ptr<SpdySerializedFrame> stream1_body( | 5582 std::unique_ptr<SpdySerializedFrame> stream1_body( |
| 5577 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5583 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5578 MockRead reads[] = { | 5584 MockRead reads[] = { |
| 5579 CreateMockRead(*stream1_reply, 1), | 5585 CreateMockRead(*stream1_reply, 1), |
| 5580 CreateMockRead(*stream1_headers, 2), | 5586 CreateMockRead(*stream1_headers, 2), |
| 5581 CreateMockRead(*stream1_body, 3), | 5587 CreateMockRead(*stream1_body, 3), |
| 5582 MockRead(ASYNC, 0, 5) // EOF | 5588 MockRead(ASYNC, 0, 5) // EOF |
| 5583 }; | 5589 }; |
| 5584 | 5590 |
| 5585 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 5591 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5603 }; | 5609 }; |
| 5604 | 5610 |
| 5605 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 5611 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 5606 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5612 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5607 std::unique_ptr<SpdySerializedFrame> stream1_body( | 5613 std::unique_ptr<SpdySerializedFrame> stream1_body( |
| 5608 spdy_util_.ConstructSpdyBodyFrame(1, false)); | 5614 spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 5609 | 5615 |
| 5610 SpdyHeaderBlock late_headers; | 5616 SpdyHeaderBlock late_headers; |
| 5611 late_headers["hello"] = "bye"; | 5617 late_headers["hello"] = "bye"; |
| 5612 std::unique_ptr<SpdySerializedFrame> stream1_headers( | 5618 std::unique_ptr<SpdySerializedFrame> stream1_headers( |
| 5613 spdy_util_.ConstructSpdyResponseHeaders(1, late_headers, false)); | 5619 spdy_util_.ConstructSpdyResponseHeaders(1, std::move(late_headers), |
| 5620 false)); |
| 5614 std::unique_ptr<SpdySerializedFrame> stream1_body2( | 5621 std::unique_ptr<SpdySerializedFrame> stream1_body2( |
| 5615 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5622 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5616 MockRead reads[] = { | 5623 MockRead reads[] = { |
| 5617 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream1_body, 2), | 5624 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream1_body, 2), |
| 5618 CreateMockRead(*stream1_headers, 3), CreateMockRead(*stream1_body2, 4), | 5625 CreateMockRead(*stream1_headers, 3), CreateMockRead(*stream1_body2, 4), |
| 5619 MockRead(ASYNC, 0, 6) // EOF | 5626 MockRead(ASYNC, 0, 6) // EOF |
| 5620 }; | 5627 }; |
| 5621 | 5628 |
| 5622 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 5629 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 5623 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5630 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| (...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7004 } | 7011 } |
| 7005 | 7012 |
| 7006 // Read in WINDOW_UPDATE or SETTINGS frame. | 7013 // Read in WINDOW_UPDATE or SETTINGS frame. |
| 7007 data.Resume(); | 7014 data.Resume(); |
| 7008 base::RunLoop().RunUntilIdle(); | 7015 base::RunLoop().RunUntilIdle(); |
| 7009 rv = callback.WaitForResult(); | 7016 rv = callback.WaitForResult(); |
| 7010 helper.VerifyDataConsumed(); | 7017 helper.VerifyDataConsumed(); |
| 7011 } | 7018 } |
| 7012 | 7019 |
| 7013 TEST_P(SpdyNetworkTransactionTest, GoAwayOnOddPushStreamId) { | 7020 TEST_P(SpdyNetworkTransactionTest, GoAwayOnOddPushStreamId) { |
| 7014 std::unique_ptr<SpdyHeaderBlock> push_headers(new SpdyHeaderBlock); | 7021 SpdyHeaderBlock push_headers; |
| 7015 spdy_util_.AddUrlToHeaderBlock("http://www.example.org/a.dat", | 7022 spdy_util_.AddUrlToHeaderBlock("http://www.example.org/a.dat", &push_headers); |
| 7016 push_headers.get()); | |
| 7017 std::unique_ptr<SpdySerializedFrame> push( | 7023 std::unique_ptr<SpdySerializedFrame> push( |
| 7018 spdy_util_.ConstructInitialSpdyPushFrame(std::move(push_headers), 3, 1)); | 7024 spdy_util_.ConstructInitialSpdyPushFrame(std::move(push_headers), 3, 1)); |
| 7019 MockRead reads[] = {CreateMockRead(*push, 1)}; | 7025 MockRead reads[] = {CreateMockRead(*push, 1)}; |
| 7020 | 7026 |
| 7021 std::unique_ptr<SpdySerializedFrame> req( | 7027 std::unique_ptr<SpdySerializedFrame> req( |
| 7022 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 7028 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 7023 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( | 7029 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( |
| 7024 0, GOAWAY_PROTOCOL_ERROR, "Odd push stream id.")); | 7030 0, GOAWAY_PROTOCOL_ERROR, "Odd push stream id.")); |
| 7025 MockWrite writes[] = { | 7031 MockWrite writes[] = { |
| 7026 CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2), | 7032 CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2), |
| 7027 }; | 7033 }; |
| 7028 | 7034 |
| 7029 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 7035 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 7030 NormalSpdyTransactionHelper helper( | 7036 NormalSpdyTransactionHelper helper( |
| 7031 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 7037 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
| 7032 helper.RunToCompletion(&data); | 7038 helper.RunToCompletion(&data); |
| 7033 TransactionHelperResult out = helper.output(); | 7039 TransactionHelperResult out = helper.output(); |
| 7034 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 7040 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
| 7035 } | 7041 } |
| 7036 | 7042 |
| 7037 TEST_P(SpdyNetworkTransactionTest, | 7043 TEST_P(SpdyNetworkTransactionTest, |
| 7038 GoAwayOnPushStreamIdLesserOrEqualThanLastAccepted) { | 7044 GoAwayOnPushStreamIdLesserOrEqualThanLastAccepted) { |
| 7039 std::unique_ptr<SpdySerializedFrame> push_a(spdy_util_.ConstructSpdyPush( | 7045 std::unique_ptr<SpdySerializedFrame> push_a(spdy_util_.ConstructSpdyPush( |
| 7040 NULL, 0, 4, 1, GetDefaultUrlWithPath("/a.dat").c_str())); | 7046 NULL, 0, 4, 1, GetDefaultUrlWithPath("/a.dat").c_str())); |
| 7041 std::unique_ptr<SpdyHeaderBlock> push_b_headers(new SpdyHeaderBlock); | 7047 SpdyHeaderBlock push_b_headers; |
| 7042 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/b.dat"), | 7048 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/b.dat"), |
| 7043 push_b_headers.get()); | 7049 &push_b_headers); |
| 7044 std::unique_ptr<SpdySerializedFrame> push_b( | 7050 std::unique_ptr<SpdySerializedFrame> push_b( |
| 7045 spdy_util_.ConstructInitialSpdyPushFrame(std::move(push_b_headers), 2, | 7051 spdy_util_.ConstructInitialSpdyPushFrame(std::move(push_b_headers), 2, |
| 7046 1)); | 7052 1)); |
| 7047 MockRead reads[] = { | 7053 MockRead reads[] = { |
| 7048 CreateMockRead(*push_a, 1), CreateMockRead(*push_b, 2), | 7054 CreateMockRead(*push_a, 1), CreateMockRead(*push_b, 2), |
| 7049 }; | 7055 }; |
| 7050 | 7056 |
| 7051 std::unique_ptr<SpdySerializedFrame> req( | 7057 std::unique_ptr<SpdySerializedFrame> req( |
| 7052 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 7058 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 7053 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( | 7059 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 7069 // and thus sent in multiple frames when using HTTP/2. | 7075 // and thus sent in multiple frames when using HTTP/2. |
| 7070 TEST_P(SpdyNetworkTransactionTest, LargeRequest) { | 7076 TEST_P(SpdyNetworkTransactionTest, LargeRequest) { |
| 7071 const std::string kKey("foo"); | 7077 const std::string kKey("foo"); |
| 7072 const std::string kValue(1 << 15, 'z'); | 7078 const std::string kValue(1 << 15, 'z'); |
| 7073 | 7079 |
| 7074 HttpRequestInfo request; | 7080 HttpRequestInfo request; |
| 7075 request.method = "GET"; | 7081 request.method = "GET"; |
| 7076 request.url = GURL(GetDefaultUrl()); | 7082 request.url = GURL(GetDefaultUrl()); |
| 7077 request.extra_headers.SetHeader(kKey, kValue); | 7083 request.extra_headers.SetHeader(kKey, kValue); |
| 7078 | 7084 |
| 7079 std::unique_ptr<SpdyHeaderBlock> headers( | 7085 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); |
| 7080 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); | 7086 headers[kKey] = kValue; |
| 7081 (*headers)[kKey] = kValue; | |
| 7082 std::unique_ptr<SpdySerializedFrame> req( | 7087 std::unique_ptr<SpdySerializedFrame> req( |
| 7083 spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, true)); | 7088 spdy_util_.ConstructSpdySyn(1, std::move(headers), LOWEST, true)); |
| 7084 MockWrite writes[] = { | 7089 MockWrite writes[] = { |
| 7085 CreateMockWrite(*req, 0), | 7090 CreateMockWrite(*req, 0), |
| 7086 }; | 7091 }; |
| 7087 | 7092 |
| 7088 std::unique_ptr<SpdySerializedFrame> resp( | 7093 std::unique_ptr<SpdySerializedFrame> resp( |
| 7089 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 7094 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); |
| 7090 std::unique_ptr<SpdySerializedFrame> body( | 7095 std::unique_ptr<SpdySerializedFrame> body( |
| 7091 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 7096 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 7092 MockRead reads[] = { | 7097 MockRead reads[] = { |
| 7093 CreateMockRead(*resp, 1), | 7098 CreateMockRead(*resp, 1), |
| 7094 CreateMockRead(*body, 2), | 7099 CreateMockRead(*body, 2), |
| 7095 MockRead(ASYNC, 0, 3) // EOF | 7100 MockRead(ASYNC, 0, 3) // EOF |
| 7096 }; | 7101 }; |
| 7097 | 7102 |
| 7098 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 7103 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 7099 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 7104 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), |
| 7100 GetParam(), nullptr); | 7105 GetParam(), nullptr); |
| 7101 helper.RunToCompletion(&data); | 7106 helper.RunToCompletion(&data); |
| 7102 TransactionHelperResult out = helper.output(); | 7107 TransactionHelperResult out = helper.output(); |
| 7103 | 7108 |
| 7104 EXPECT_EQ(OK, out.rv); | 7109 EXPECT_EQ(OK, out.rv); |
| 7105 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 7110 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 7106 EXPECT_EQ("hello!", out.response_data); | 7111 EXPECT_EQ("hello!", out.response_data); |
| 7107 } | 7112 } |
| 7108 | 7113 |
| 7109 // Regression test for https://crbug.com/535629: response header exceeds 16 kB. | 7114 // Regression test for https://crbug.com/535629: response header exceeds 16 kB. |
| 7110 TEST_P(SpdyNetworkTransactionTest, LargeResponseHeader) { | 7115 TEST_P(SpdyNetworkTransactionTest, LargeResponseHeader) { |
| 7111 std::unique_ptr<SpdyHeaderBlock> headers( | 7116 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); |
| 7112 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); | |
| 7113 std::unique_ptr<SpdySerializedFrame> req( | 7117 std::unique_ptr<SpdySerializedFrame> req( |
| 7114 spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, true)); | 7118 spdy_util_.ConstructSpdySyn(1, std::move(headers), LOWEST, true)); |
| 7115 MockWrite writes[] = { | 7119 MockWrite writes[] = { |
| 7116 CreateMockWrite(*req, 0), | 7120 CreateMockWrite(*req, 0), |
| 7117 }; | 7121 }; |
| 7118 | 7122 |
| 7119 // HPACK decoder implementation limits string literal length to 16 kB. | 7123 // HPACK decoder implementation limits string literal length to 16 kB. |
| 7120 const char* response_headers[2]; | 7124 const char* response_headers[2]; |
| 7121 const std::string kKey(16 * 1024, 'a'); | 7125 const std::string kKey(16 * 1024, 'a'); |
| 7122 response_headers[0] = kKey.data(); | 7126 response_headers[0] = kKey.data(); |
| 7123 const std::string kValue(16 * 1024, 'b'); | 7127 const std::string kValue(16 * 1024, 'b'); |
| 7124 response_headers[1] = kValue.data(); | 7128 response_headers[1] = kValue.data(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7257 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 7261 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
| 7258 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 7262 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
| 7259 new SSLSocketDataProvider(ASYNC, OK)); | 7263 new SSLSocketDataProvider(ASYNC, OK)); |
| 7260 // Set to TLS_RSA_WITH_NULL_MD5 | 7264 // Set to TLS_RSA_WITH_NULL_MD5 |
| 7261 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 7265 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
| 7262 | 7266 |
| 7263 RunTLSUsageCheckTest(std::move(ssl_provider)); | 7267 RunTLSUsageCheckTest(std::move(ssl_provider)); |
| 7264 } | 7268 } |
| 7265 | 7269 |
| 7266 } // namespace net | 7270 } // namespace net |
| OLD | NEW |