Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1172)

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 357513003: Stop using SpdySynStreamIR for SPDY 4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WebSocket test fix. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_framer_test.cc ('k') | net/spdy/spdy_proxy_client_socket_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 helper.VerifyDataConsumed(); 1670 helper.VerifyDataConsumed();
1671 } 1671 }
1672 1672
1673 // Test that a simple PUT request works. 1673 // Test that a simple PUT request works.
1674 TEST_P(SpdyNetworkTransactionTest, Put) { 1674 TEST_P(SpdyNetworkTransactionTest, Put) {
1675 // Setup the request 1675 // Setup the request
1676 HttpRequestInfo request; 1676 HttpRequestInfo request;
1677 request.method = "PUT"; 1677 request.method = "PUT";
1678 request.url = GURL("http://www.google.com/"); 1678 request.url = GURL("http://www.google.com/");
1679 1679
1680 const SpdyHeaderInfo kSynStartHeader = {
1681 SYN_STREAM, // Kind = Syn
1682 1, // Stream ID
1683 0, // Associated stream ID
1684 ConvertRequestPriorityToSpdyPriority(
1685 LOWEST, spdy_util_.spdy_version()),
1686 kSpdyCredentialSlotUnused,
1687 CONTROL_FLAG_FIN, // Control Flags
1688 false, // Compressed
1689 RST_STREAM_INVALID, // Status
1690 NULL, // Data
1691 0, // Length
1692 DATA_FLAG_NONE // Data Flags
1693 };
1694 scoped_ptr<SpdyHeaderBlock> put_headers( 1680 scoped_ptr<SpdyHeaderBlock> put_headers(
1695 spdy_util_.ConstructPutHeaderBlock("http://www.google.com", 0)); 1681 spdy_util_.ConstructPutHeaderBlock("http://www.google.com", 0));
1696 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( 1682 scoped_ptr<SpdyFrame> req(
1697 kSynStartHeader, put_headers.Pass())); 1683 spdy_util_.ConstructSpdySyn(1, *put_headers, LOWEST, false, true));
1698 MockWrite writes[] = { 1684 MockWrite writes[] = {
1699 CreateMockWrite(*req), 1685 CreateMockWrite(*req),
1700 }; 1686 };
1701 1687
1702 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 1688 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
1703 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); 1689 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
1704 MockRead reads[] = { 1690 MockRead reads[] = {
1705 CreateMockRead(*resp), 1691 CreateMockRead(*resp),
1706 CreateMockRead(*body), 1692 CreateMockRead(*body),
1707 MockRead(ASYNC, 0, 0) // EOF 1693 MockRead(ASYNC, 0, 0) // EOF
(...skipping 10 matching lines...) Expand all
1718 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1704 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1719 } 1705 }
1720 1706
1721 // Test that a simple HEAD request works. 1707 // Test that a simple HEAD request works.
1722 TEST_P(SpdyNetworkTransactionTest, Head) { 1708 TEST_P(SpdyNetworkTransactionTest, Head) {
1723 // Setup the request 1709 // Setup the request
1724 HttpRequestInfo request; 1710 HttpRequestInfo request;
1725 request.method = "HEAD"; 1711 request.method = "HEAD";
1726 request.url = GURL("http://www.google.com/"); 1712 request.url = GURL("http://www.google.com/");
1727 1713
1728 const SpdyHeaderInfo kSynStartHeader = {
1729 SYN_STREAM, // Kind = Syn
1730 1, // Stream ID
1731 0, // Associated stream ID
1732 ConvertRequestPriorityToSpdyPriority(
1733 LOWEST, spdy_util_.spdy_version()),
1734 kSpdyCredentialSlotUnused,
1735 CONTROL_FLAG_FIN, // Control Flags
1736 false, // Compressed
1737 RST_STREAM_INVALID, // Status
1738 NULL, // Data
1739 0, // Length
1740 DATA_FLAG_NONE // Data Flags
1741 };
1742 scoped_ptr<SpdyHeaderBlock> head_headers( 1714 scoped_ptr<SpdyHeaderBlock> head_headers(
1743 spdy_util_.ConstructHeadHeaderBlock("http://www.google.com", 0)); 1715 spdy_util_.ConstructHeadHeaderBlock("http://www.google.com", 0));
1744 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( 1716 scoped_ptr<SpdyFrame> req(
1745 kSynStartHeader, head_headers.Pass())); 1717 spdy_util_.ConstructSpdySyn(1, *head_headers, LOWEST, false, true));
1746 MockWrite writes[] = { 1718 MockWrite writes[] = {
1747 CreateMockWrite(*req), 1719 CreateMockWrite(*req),
1748 }; 1720 };
1749 1721
1750 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 1722 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
1751 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); 1723 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
1752 MockRead reads[] = { 1724 MockRead reads[] = {
1753 CreateMockRead(*resp), 1725 CreateMockRead(*resp),
1754 CreateMockRead(*body), 1726 CreateMockRead(*body),
1755 MockRead(ASYNC, 0, 0) // EOF 1727 MockRead(ASYNC, 0, 0) // EOF
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); 1945 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false);
1974 // Setup the request 1946 // Setup the request
1975 HttpRequestInfo request; 1947 HttpRequestInfo request;
1976 request.method = "POST"; 1948 request.method = "POST";
1977 request.url = GURL(kRequestUrl); 1949 request.url = GURL(kRequestUrl);
1978 // Create an empty UploadData. 1950 // Create an empty UploadData.
1979 request.upload_data_stream = NULL; 1951 request.upload_data_stream = NULL;
1980 1952
1981 // When request.upload_data_stream is NULL for post, content-length is 1953 // When request.upload_data_stream is NULL for post, content-length is
1982 // expected to be 0. 1954 // expected to be 0.
1983 SpdySynStreamIR syn_ir(1); 1955 scoped_ptr<SpdyHeaderBlock> req_block(
1984 syn_ir.set_name_value_block( 1956 spdy_util_.ConstructPostHeaderBlock(kRequestUrl, 0));
1985 *spdy_util_.ConstructPostHeaderBlock(kRequestUrl, 0)); 1957 scoped_ptr<SpdyFrame> req(
1986 syn_ir.set_fin(true); // No body. 1958 spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, false, true));
1987 syn_ir.set_priority(ConvertRequestPriorityToSpdyPriority(
1988 LOWEST, spdy_util_.spdy_version()));
1989 scoped_ptr<SpdyFrame> req(framer.SerializeFrame(syn_ir));
1990 1959
1991 MockWrite writes[] = { 1960 MockWrite writes[] = {
1992 CreateMockWrite(*req), 1961 CreateMockWrite(*req),
1993 }; 1962 };
1994 1963
1995 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); 1964 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
1996 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); 1965 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
1997 MockRead reads[] = { 1966 MockRead reads[] = {
1998 CreateMockRead(*resp), 1967 CreateMockRead(*resp),
1999 CreateMockRead(*body), 1968 CreateMockRead(*body),
(...skipping 20 matching lines...) Expand all
2020 UploadDataStream stream(element_readers.Pass(), 0); 1989 UploadDataStream stream(element_readers.Pass(), 0);
2021 1990
2022 // Setup the request 1991 // Setup the request
2023 HttpRequestInfo request; 1992 HttpRequestInfo request;
2024 request.method = "POST"; 1993 request.method = "POST";
2025 request.url = GURL(kRequestUrl); 1994 request.url = GURL(kRequestUrl);
2026 request.upload_data_stream = &stream; 1995 request.upload_data_stream = &stream;
2027 1996
2028 const uint64 kContentLength = 0; 1997 const uint64 kContentLength = 0;
2029 1998
2030 SpdySynStreamIR syn_ir(1); 1999 scoped_ptr<SpdyHeaderBlock> req_block(
2031 syn_ir.set_name_value_block( 2000 spdy_util_.ConstructPostHeaderBlock(kRequestUrl, kContentLength));
2032 *spdy_util_.ConstructPostHeaderBlock(kRequestUrl, kContentLength)); 2001 scoped_ptr<SpdyFrame> req(
2033 syn_ir.set_fin(true); // No body. 2002 spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, false, true));
2034 syn_ir.set_priority(ConvertRequestPriorityToSpdyPriority(
2035 LOWEST, spdy_util_.spdy_version()));
2036 scoped_ptr<SpdyFrame> req(framer.SerializeFrame(syn_ir));
2037 2003
2038 MockWrite writes[] = { 2004 MockWrite writes[] = {
2039 CreateMockWrite(*req), 2005 CreateMockWrite(*req),
2040 }; 2006 };
2041 2007
2042 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); 2008 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
2043 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); 2009 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
2044 MockRead reads[] = { 2010 MockRead reads[] = {
2045 CreateMockRead(*resp), 2011 CreateMockRead(*resp),
2046 CreateMockRead(*body), 2012 CreateMockRead(*body),
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
2477 ASSERT_EQ(ERR_IO_PENDING, rv); 2443 ASSERT_EQ(ERR_IO_PENDING, rv);
2478 data.CompleteRead(); 2444 data.CompleteRead();
2479 2445
2480 // Finish running rest of tasks. 2446 // Finish running rest of tasks.
2481 base::RunLoop().RunUntilIdle(); 2447 base::RunLoop().RunUntilIdle();
2482 helper.VerifyDataConsumed(); 2448 helper.VerifyDataConsumed();
2483 } 2449 }
2484 2450
2485 // Send a spdy request to www.google.com that gets redirected to www.foo.com. 2451 // Send a spdy request to www.google.com that gets redirected to www.foo.com.
2486 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { 2452 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) {
2487 const SpdyHeaderInfo kSynStartHeader = spdy_util_.MakeSpdyHeader(SYN_STREAM);
2488 scoped_ptr<SpdyHeaderBlock> headers( 2453 scoped_ptr<SpdyHeaderBlock> headers(
2489 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); 2454 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/"));
2490 (*headers)["user-agent"] = ""; 2455 (*headers)["user-agent"] = "";
2491 (*headers)["accept-encoding"] = "gzip,deflate"; 2456 (*headers)["accept-encoding"] = "gzip,deflate";
2492 scoped_ptr<SpdyHeaderBlock> headers2( 2457 scoped_ptr<SpdyHeaderBlock> headers2(
2493 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); 2458 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php"));
2494 (*headers2)["user-agent"] = ""; 2459 (*headers2)["user-agent"] = "";
2495 (*headers2)["accept-encoding"] = "gzip,deflate"; 2460 (*headers2)["accept-encoding"] = "gzip,deflate";
2496 2461
2497 // Setup writes/reads to www.google.com 2462 // Setup writes/reads to www.google.com
2498 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame( 2463 scoped_ptr<SpdyFrame> req(
2499 kSynStartHeader, headers.Pass())); 2464 spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, false, true));
2500 scoped_ptr<SpdyFrame> req2(spdy_util_.ConstructSpdyFrame( 2465 scoped_ptr<SpdyFrame> req2(
2501 kSynStartHeader, headers2.Pass())); 2466 spdy_util_.ConstructSpdySyn(1, *headers2, LOWEST, false, true));
2502 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReplyRedirect(1)); 2467 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReplyRedirect(1));
2503 MockWrite writes[] = { 2468 MockWrite writes[] = {
2504 CreateMockWrite(*req, 1), 2469 CreateMockWrite(*req, 1),
2505 }; 2470 };
2506 MockRead reads[] = { 2471 MockRead reads[] = {
2507 CreateMockRead(*resp, 2), 2472 CreateMockRead(*resp, 2),
2508 MockRead(ASYNC, 0, 0, 3) // EOF 2473 MockRead(ASYNC, 0, 0, 3) // EOF
2509 }; 2474 };
2510 2475
2511 // Setup writes/reads to www.foo.com 2476 // Setup writes/reads to www.foo.com
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 } 2521 }
2557 EXPECT_TRUE(data.at_read_eof()); 2522 EXPECT_TRUE(data.at_read_eof());
2558 EXPECT_TRUE(data.at_write_eof()); 2523 EXPECT_TRUE(data.at_write_eof());
2559 EXPECT_TRUE(data2.at_read_eof()); 2524 EXPECT_TRUE(data2.at_read_eof());
2560 EXPECT_TRUE(data2.at_write_eof()); 2525 EXPECT_TRUE(data2.at_write_eof());
2561 } 2526 }
2562 2527
2563 // Send a spdy request to www.google.com. Get a pushed stream that redirects to 2528 // Send a spdy request to www.google.com. Get a pushed stream that redirects to
2564 // www.foo.com. 2529 // www.foo.com.
2565 TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { 2530 TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) {
2566 const SpdyHeaderInfo kSynStartHeader = spdy_util_.MakeSpdyHeader(SYN_STREAM);
2567
2568 scoped_ptr<SpdyHeaderBlock> headers( 2531 scoped_ptr<SpdyHeaderBlock> headers(
2569 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); 2532 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/"));
2570 (*headers)["user-agent"] = ""; 2533 (*headers)["user-agent"] = "";
2571 (*headers)["accept-encoding"] = "gzip,deflate"; 2534 (*headers)["accept-encoding"] = "gzip,deflate";
2572 2535
2573 // Setup writes/reads to www.google.com 2536 // Setup writes/reads to www.google.com
2574 scoped_ptr<SpdyFrame> req( 2537 scoped_ptr<SpdyFrame> req(
2575 spdy_util_.ConstructSpdyFrame(kSynStartHeader, headers.Pass())); 2538 spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, false, true));
2576 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 2539 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
2577 scoped_ptr<SpdyFrame> rep( 2540 scoped_ptr<SpdyFrame> rep(
2578 spdy_util_.ConstructSpdyPush(NULL, 2541 spdy_util_.ConstructSpdyPush(NULL,
2579 0, 2542 0,
2580 2, 2543 2,
2581 1, 2544 1,
2582 "http://www.google.com/foo.dat", 2545 "http://www.google.com/foo.dat",
2583 "301 Moved Permanently", 2546 "301 Moved Permanently",
2584 "http://www.foo.com/index.php")); 2547 "http://www.foo.com/index.php"));
2585 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); 2548 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
(...skipping 10 matching lines...) Expand all
2596 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause 2559 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause
2597 MockRead(ASYNC, 0, 0, 7) // EOF 2560 MockRead(ASYNC, 0, 0, 7) // EOF
2598 }; 2561 };
2599 2562
2600 // Setup writes/reads to www.foo.com 2563 // Setup writes/reads to www.foo.com
2601 scoped_ptr<SpdyHeaderBlock> headers2( 2564 scoped_ptr<SpdyHeaderBlock> headers2(
2602 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); 2565 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php"));
2603 (*headers2)["user-agent"] = ""; 2566 (*headers2)["user-agent"] = "";
2604 (*headers2)["accept-encoding"] = "gzip,deflate"; 2567 (*headers2)["accept-encoding"] = "gzip,deflate";
2605 scoped_ptr<SpdyFrame> req2( 2568 scoped_ptr<SpdyFrame> req2(
2606 spdy_util_.ConstructSpdyFrame(kSynStartHeader, headers2.Pass())); 2569 spdy_util_.ConstructSpdySyn(1, *headers2, LOWEST, false, true));
2607 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 2570 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
2608 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(1, true)); 2571 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(1, true));
2609 MockWrite writes2[] = { 2572 MockWrite writes2[] = {
2610 CreateMockWrite(*req2, 1), 2573 CreateMockWrite(*req2, 1),
2611 }; 2574 };
2612 MockRead reads2[] = { 2575 MockRead reads2[] = {
2613 CreateMockRead(*resp2, 2), 2576 CreateMockRead(*resp2, 2),
2614 CreateMockRead(*body2, 3), 2577 CreateMockRead(*body2, 3),
2615 MockRead(ASYNC, 0, 0, 5) // EOF 2578 MockRead(ASYNC, 0, 0, 5) // EOF
2616 }; 2579 };
(...skipping 3982 matching lines...) Expand 10 before | Expand all | Expand 10 after
6599 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { 6562 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) {
6600 scoped_ptr<SSLSocketDataProvider> ssl_provider( 6563 scoped_ptr<SSLSocketDataProvider> ssl_provider(
6601 new SSLSocketDataProvider(ASYNC, OK)); 6564 new SSLSocketDataProvider(ASYNC, OK));
6602 // Set to TLS_RSA_WITH_NULL_MD5 6565 // Set to TLS_RSA_WITH_NULL_MD5
6603 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); 6566 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status);
6604 6567
6605 RunTLSUsageCheckTest(ssl_provider.Pass()); 6568 RunTLSUsageCheckTest(ssl_provider.Pass());
6606 } 6569 }
6607 6570
6608 } // namespace net 6571 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer_test.cc ('k') | net/spdy/spdy_proxy_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698