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

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

Issue 9705046: Switch CreateSpdyHeadersFromHttpRequest to construct the correct headers based on the spdy protocol… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
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 "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 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 0, // Associated stream ID 1452 0, // Associated stream ID
1453 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1453 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
1454 spdy::CONTROL_FLAG_FIN, // Control Flags 1454 spdy::CONTROL_FLAG_FIN, // Control Flags
1455 false, // Compressed 1455 false, // Compressed
1456 spdy::INVALID, // Status 1456 spdy::INVALID, // Status
1457 NULL, // Data 1457 NULL, // Data
1458 0, // Length 1458 0, // Length
1459 spdy::DATA_FLAG_NONE // Data Flags 1459 spdy::DATA_FLAG_NONE // Data Flags
1460 }; 1460 };
1461 const char* const kPutHeaders[] = { 1461 const char* const kPutHeaders[] = {
1462 "method", "PUT", 1462 ":method", "PUT",
1463 "url", "/", 1463 ":path", "/",
1464 "host", "www.google.com", 1464 ":host", "www.google.com",
1465 "scheme", "http", 1465 ":scheme", "http",
1466 "version", "HTTP/1.1", 1466 ":version", "HTTP/1.1",
1467 "content-length", "0" 1467 "content-length", "0"
1468 }; 1468 };
1469 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, 1469 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0,
1470 kPutHeaders, arraysize(kPutHeaders) / 2)); 1470 kPutHeaders, arraysize(kPutHeaders) / 2));
1471 MockWrite writes[] = { 1471 MockWrite writes[] = {
1472 CreateMockWrite(*req) 1472 CreateMockWrite(*req)
1473 }; 1473 };
1474 1474
1475 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 1475 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1476 const SpdyHeaderInfo kSynReplyHeader = { 1476 const SpdyHeaderInfo kSynReplyHeader = {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 0, // Associated stream ID 1523 0, // Associated stream ID
1524 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1524 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
1525 spdy::CONTROL_FLAG_FIN, // Control Flags 1525 spdy::CONTROL_FLAG_FIN, // Control Flags
1526 false, // Compressed 1526 false, // Compressed
1527 spdy::INVALID, // Status 1527 spdy::INVALID, // Status
1528 NULL, // Data 1528 NULL, // Data
1529 0, // Length 1529 0, // Length
1530 spdy::DATA_FLAG_NONE // Data Flags 1530 spdy::DATA_FLAG_NONE // Data Flags
1531 }; 1531 };
1532 const char* const kHeadHeaders[] = { 1532 const char* const kHeadHeaders[] = {
1533 "method", "HEAD", 1533 ":method", "HEAD",
1534 "url", "/", 1534 ":path", "/",
1535 "host", "www.google.com", 1535 ":host", "www.google.com",
1536 "scheme", "http", 1536 ":scheme", "http",
1537 "version", "HTTP/1.1", 1537 ":version", "HTTP/1.1",
1538 "content-length", "0" 1538 "content-length", "0"
1539 }; 1539 };
1540 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, 1540 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0,
1541 kHeadHeaders, arraysize(kHeadHeaders) / 2)); 1541 kHeadHeaders, arraysize(kHeadHeaders) / 2));
1542 MockWrite writes[] = { 1542 MockWrite writes[] = {
1543 CreateMockWrite(*req) 1543 CreateMockWrite(*req)
1544 }; 1544 };
1545 1545
1546 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 1546 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1547 const SpdyHeaderInfo kSynReplyHeader = { 1547 const SpdyHeaderInfo kSynReplyHeader = {
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 2427
2428 // Send a spdy request to www.google.com that gets redirected to www.foo.com. 2428 // Send a spdy request to www.google.com that gets redirected to www.foo.com.
2429 TEST_P(SpdyNetworkTransactionSpdy3Test, RedirectGetRequest) { 2429 TEST_P(SpdyNetworkTransactionSpdy3Test, RedirectGetRequest) {
2430 // These are headers which the net::URLRequest tacks on. 2430 // These are headers which the net::URLRequest tacks on.
2431 const char* const kExtraHeaders[] = { 2431 const char* const kExtraHeaders[] = {
2432 "accept-encoding", 2432 "accept-encoding",
2433 "gzip,deflate", 2433 "gzip,deflate",
2434 }; 2434 };
2435 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); 2435 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM);
2436 const char* const kStandardGetHeaders[] = { 2436 const char* const kStandardGetHeaders[] = {
2437 "host", 2437 ":host",
2438 "www.google.com", 2438 "www.google.com",
2439 "method", 2439 ":method",
2440 "GET", 2440 "GET",
2441 "scheme", 2441 ":scheme",
2442 "http", 2442 "http",
2443 "url", 2443 ":path",
2444 "/", 2444 "/",
2445 "user-agent", 2445 "user-agent",
2446 "", 2446 "",
2447 "version", 2447 ":version",
2448 "HTTP/1.1" 2448 "HTTP/1.1"
2449 }; 2449 };
2450 const char* const kStandardGetHeaders2[] = { 2450 const char* const kStandardGetHeaders2[] = {
2451 "host", 2451 ":host",
2452 "www.foo.com", 2452 "www.foo.com",
2453 "method", 2453 ":method",
2454 "GET", 2454 "GET",
2455 "scheme", 2455 ":scheme",
2456 "http", 2456 "http",
2457 "url", 2457 ":path",
2458 "/index.php", 2458 "/index.php",
2459 "user-agent", 2459 "user-agent",
2460 "", 2460 "",
2461 "version", 2461 ":version",
2462 "HTTP/1.1" 2462 "HTTP/1.1"
2463 }; 2463 };
2464 2464
2465 // Setup writes/reads to www.google.com 2465 // Setup writes/reads to www.google.com
2466 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPacket( 2466 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPacket(
2467 kSynStartHeader, kExtraHeaders, arraysize(kExtraHeaders) / 2, 2467 kSynStartHeader, kExtraHeaders, arraysize(kExtraHeaders) / 2,
2468 kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); 2468 kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2));
2469 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyPacket( 2469 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyPacket(
2470 kSynStartHeader, kExtraHeaders, arraysize(kExtraHeaders) / 2, 2470 kSynStartHeader, kExtraHeaders, arraysize(kExtraHeaders) / 2,
2471 kStandardGetHeaders2, arraysize(kStandardGetHeaders2) / 2)); 2471 kStandardGetHeaders2, arraysize(kStandardGetHeaders2) / 2));
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 // Send a spdy request to www.google.com. Get a pushed stream that redirects to 2663 // Send a spdy request to www.google.com. Get a pushed stream that redirects to
2664 // www.foo.com. 2664 // www.foo.com.
2665 TEST_P(SpdyNetworkTransactionSpdy3Test, RedirectServerPush) { 2665 TEST_P(SpdyNetworkTransactionSpdy3Test, RedirectServerPush) {
2666 // These are headers which the net::URLRequest tacks on. 2666 // These are headers which the net::URLRequest tacks on.
2667 const char* const kExtraHeaders[] = { 2667 const char* const kExtraHeaders[] = {
2668 "accept-encoding", 2668 "accept-encoding",
2669 "gzip,deflate", 2669 "gzip,deflate",
2670 }; 2670 };
2671 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); 2671 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM);
2672 const char* const kStandardGetHeaders[] = { 2672 const char* const kStandardGetHeaders[] = {
2673 "host", 2673 ":host",
2674 "www.google.com", 2674 "www.google.com",
2675 "method", 2675 ":method",
2676 "GET", 2676 "GET",
2677 "scheme", 2677 ":scheme",
2678 "http", 2678 "http",
2679 "url", 2679 ":path",
2680 "/", 2680 "/",
2681 "user-agent", 2681 "user-agent",
2682 "", 2682 "",
2683 "version", 2683 ":version",
2684 "HTTP/1.1" 2684 "HTTP/1.1"
2685 }; 2685 };
2686 2686
2687 // Setup writes/reads to www.google.com 2687 // Setup writes/reads to www.google.com
2688 scoped_ptr<spdy::SpdyFrame> req( 2688 scoped_ptr<spdy::SpdyFrame> req(
2689 ConstructSpdyPacket(kSynStartHeader, 2689 ConstructSpdyPacket(kSynStartHeader,
2690 kExtraHeaders, 2690 kExtraHeaders,
2691 arraysize(kExtraHeaders) / 2, 2691 arraysize(kExtraHeaders) / 2,
2692 kStandardGetHeaders, 2692 kStandardGetHeaders,
2693 arraysize(kStandardGetHeaders) / 2)); 2693 arraysize(kStandardGetHeaders) / 2));
(...skipping 15 matching lines...) Expand all
2709 MockRead reads[] = { 2709 MockRead reads[] = {
2710 CreateMockRead(*resp, 2), 2710 CreateMockRead(*resp, 2),
2711 CreateMockRead(*rep, 3), 2711 CreateMockRead(*rep, 3),
2712 CreateMockRead(*body, 4), 2712 CreateMockRead(*body, 4),
2713 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause 2713 MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause
2714 MockRead(ASYNC, 0, 0, 7) // EOF 2714 MockRead(ASYNC, 0, 0, 7) // EOF
2715 }; 2715 };
2716 2716
2717 // Setup writes/reads to www.foo.com 2717 // Setup writes/reads to www.foo.com
2718 const char* const kStandardGetHeaders2[] = { 2718 const char* const kStandardGetHeaders2[] = {
2719 "host", 2719 ":host",
2720 "www.foo.com", 2720 "www.foo.com",
2721 "method", 2721 ":method",
2722 "GET", 2722 "GET",
2723 "scheme", 2723 ":scheme",
2724 "http", 2724 "http",
2725 "url", 2725 ":path",
2726 "/index.php", 2726 "/index.php",
2727 "user-agent", 2727 "user-agent",
2728 "", 2728 "",
2729 "version", 2729 ":version",
2730 "HTTP/1.1" 2730 "HTTP/1.1"
2731 }; 2731 };
2732 scoped_ptr<spdy::SpdyFrame> req2( 2732 scoped_ptr<spdy::SpdyFrame> req2(
2733 ConstructSpdyPacket(kSynStartHeader, 2733 ConstructSpdyPacket(kSynStartHeader,
2734 kExtraHeaders, 2734 kExtraHeaders,
2735 arraysize(kExtraHeaders) / 2, 2735 arraysize(kExtraHeaders) / 2,
2736 kStandardGetHeaders2, 2736 kStandardGetHeaders2,
2737 arraysize(kStandardGetHeaders2) / 2)); 2737 arraysize(kStandardGetHeaders2) / 2));
2738 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 1)); 2738 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 1));
2739 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(1, true)); 2739 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(1, true));
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
3898 entries, 0, 3898 entries, 0,
3899 net::NetLog::TYPE_SPDY_SESSION_SYN_STREAM, 3899 net::NetLog::TYPE_SPDY_SESSION_SYN_STREAM,
3900 net::NetLog::PHASE_NONE); 3900 net::NetLog::PHASE_NONE);
3901 CapturingNetLog::Entry entry = entries[pos]; 3901 CapturingNetLog::Entry entry = entries[pos];
3902 NetLogSpdySynParameter* request_params = 3902 NetLogSpdySynParameter* request_params =
3903 static_cast<NetLogSpdySynParameter*>(entry.extra_parameters.get()); 3903 static_cast<NetLogSpdySynParameter*>(entry.extra_parameters.get());
3904 spdy::SpdyHeaderBlock* headers = 3904 spdy::SpdyHeaderBlock* headers =
3905 request_params->GetHeaders().get(); 3905 request_params->GetHeaders().get();
3906 3906
3907 spdy::SpdyHeaderBlock expected; 3907 spdy::SpdyHeaderBlock expected;
3908 expected["host"] = "www.google.com"; 3908 expected[":host"] = "www.google.com";
3909 expected["url"] = "/"; 3909 expected[":path"] = "/";
3910 expected["scheme"] = "http"; 3910 expected[":scheme"] = "http";
3911 expected["version"] = "HTTP/1.1"; 3911 expected[":version"] = "HTTP/1.1";
3912 expected["method"] = "GET"; 3912 expected[":method"] = "GET";
3913 expected["user-agent"] = "Chrome"; 3913 expected["user-agent"] = "Chrome";
3914 EXPECT_EQ(expected.size(), headers->size()); 3914 EXPECT_EQ(expected.size(), headers->size());
3915 spdy::SpdyHeaderBlock::const_iterator end = expected.end(); 3915 spdy::SpdyHeaderBlock::const_iterator end = expected.end();
3916 for (spdy::SpdyHeaderBlock::const_iterator it = expected.begin(); 3916 for (spdy::SpdyHeaderBlock::const_iterator it = expected.begin();
3917 it != end; 3917 it != end;
3918 ++it) { 3918 ++it) {
3919 EXPECT_EQ(it->second, (*headers)[it->first]); 3919 EXPECT_EQ(it->second, (*headers)[it->first]);
3920 } 3920 }
3921 } 3921 }
3922 3922
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
5862 << " Write index: " 5862 << " Write index: "
5863 << data->write_index(); 5863 << data->write_index();
5864 5864
5865 // Verify the SYN_REPLY. 5865 // Verify the SYN_REPLY.
5866 HttpResponseInfo response = *trans->GetResponseInfo(); 5866 HttpResponseInfo response = *trans->GetResponseInfo();
5867 EXPECT_TRUE(response.headers != NULL); 5867 EXPECT_TRUE(response.headers != NULL);
5868 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5868 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5869 } 5869 }
5870 5870
5871 } // namespace net 5871 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698