OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/tools/quic/spdy_balsa_utils.h" | 5 #include "net/tools/quic/spdy_balsa_utils.h" |
6 | 6 |
7 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" |
8 #include "net/spdy/spdy_test_utils.h" | 8 #include "net/spdy/spdy_test_utils.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 SpdyHeaderBlock expected_headers; | 25 SpdyHeaderBlock expected_headers; |
26 expected_headers[":authority"] = "www.google.com"; | 26 expected_headers[":authority"] = "www.google.com"; |
27 expected_headers[":path"] = "/foo"; | 27 expected_headers[":path"] = "/foo"; |
28 expected_headers[":scheme"] = "https"; | 28 expected_headers[":scheme"] = "https"; |
29 expected_headers[":method"] = "GET"; | 29 expected_headers[":method"] = "GET"; |
30 | 30 |
31 EXPECT_EQ(expected_headers, spdy_headers); | 31 EXPECT_EQ(expected_headers, spdy_headers); |
32 } | 32 } |
33 | 33 |
| 34 TEST(SpdyBalsaUtilsTest, RequestHeadersToSpdyHeadersRelativeUri) { |
| 35 BalsaHeaders request_headers; |
| 36 request_headers.SetRequestFirstlineFromStringPieces("GET", "/", "HTTP/1.1"); |
| 37 SpdyHeaderBlock spdy_headers = |
| 38 SpdyBalsaUtils::RequestHeadersToSpdyHeaders(request_headers); |
| 39 |
| 40 SpdyHeaderBlock expected_headers; |
| 41 expected_headers[":authority"] = ""; |
| 42 expected_headers[":path"] = "/"; |
| 43 expected_headers[":scheme"] = "https"; |
| 44 expected_headers[":method"] = "GET"; |
| 45 |
| 46 EXPECT_EQ(expected_headers, spdy_headers); |
| 47 } |
| 48 |
| 49 TEST(SpdyBalsaUtilsTest, RequestHeadersToSpdyHeadersExplicitScheme) { |
| 50 BalsaHeaders request_headers; |
| 51 request_headers.SetRequestFirstlineFromStringPieces("GET", "/", "HTTP/1.1"); |
| 52 request_headers.AppendHeader("Scheme", "http"); |
| 53 SpdyHeaderBlock spdy_headers = |
| 54 SpdyBalsaUtils::RequestHeadersToSpdyHeaders(request_headers); |
| 55 |
| 56 SpdyHeaderBlock expected_headers; |
| 57 expected_headers[":authority"] = ""; |
| 58 expected_headers[":path"] = "/"; |
| 59 expected_headers[":scheme"] = "http"; |
| 60 expected_headers[":method"] = "GET"; |
| 61 |
| 62 EXPECT_EQ(expected_headers, spdy_headers); |
| 63 } |
| 64 |
34 TEST(SpdyBalsaUtilsTest, ResponseHeadersToSpdyHeaders) { | 65 TEST(SpdyBalsaUtilsTest, ResponseHeadersToSpdyHeaders) { |
35 BalsaHeaders response_headers; | 66 BalsaHeaders response_headers; |
36 response_headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", | 67 response_headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", |
37 "OK"); | 68 "OK"); |
38 SpdyHeaderBlock spdy_headers = | 69 SpdyHeaderBlock spdy_headers = |
39 SpdyBalsaUtils::ResponseHeadersToSpdyHeaders(response_headers); | 70 SpdyBalsaUtils::ResponseHeadersToSpdyHeaders(response_headers); |
40 | 71 |
41 SpdyHeaderBlock expected_headers; | 72 SpdyHeaderBlock expected_headers; |
42 expected_headers[":status"] = "200"; | 73 expected_headers[":status"] = "200"; |
43 | 74 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 EXPECT_TRUE(response_headers.HasHeader("bar")); | 123 EXPECT_TRUE(response_headers.HasHeader("bar")); |
93 EXPECT_EQ("", response_headers.GetHeader("bar")); | 124 EXPECT_EQ("", response_headers.GetHeader("bar")); |
94 std::vector<StringPiece> pieces; | 125 std::vector<StringPiece> pieces; |
95 response_headers.GetAllOfHeader("foo", &pieces); | 126 response_headers.GetAllOfHeader("foo", &pieces); |
96 EXPECT_THAT(pieces, ElementsAre("multi", "valued", "header")); | 127 EXPECT_THAT(pieces, ElementsAre("multi", "valued", "header")); |
97 } | 128 } |
98 | 129 |
99 } // namespace | 130 } // namespace |
100 } // namespace test | 131 } // namespace test |
101 } // namespace net | 132 } // namespace net |
OLD | NEW |