| 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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 namespace tools { | 10 namespace tools { |
| 11 namespace test { | 11 namespace test { |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 TEST(SpdyBalsaUtilsTest, RequestHeadersToSpdyHeaders) { | 14 TEST(SpdyBalsaUtilsTest, RequestHeadersToSpdyHeaders) { |
| 15 BalsaHeaders request_headers; | 15 BalsaHeaders request_headers; |
| 16 request_headers.SetRequestFirstlineFromStringPieces( | 16 request_headers.SetRequestFirstlineFromStringPieces( |
| 17 "GET", "https://www.google.com/foo", "HTTP/1.1"); | 17 "GET", "https://www.google.com/foo", "HTTP/1.1"); |
| 18 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::RequestHeadersToSpdyHeaders( | 18 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::RequestHeadersToSpdyHeaders( |
| 19 request_headers, kSupportedQuicVersions[0]); | 19 request_headers, kSupportedQuicVersions[0]); |
| 20 | 20 |
| 21 SpdyHeaderBlock expected_headers; | 21 SpdyHeaderBlock expected_headers; |
| 22 expected_headers[":authority"] = "www.google.com"; | 22 expected_headers[":authority"] = "www.google.com"; |
| 23 expected_headers[":method"] = "GET"; | |
| 24 expected_headers[":path"] = "/foo"; | 23 expected_headers[":path"] = "/foo"; |
| 25 expected_headers[":scheme"] = "https"; | 24 expected_headers[":scheme"] = "https"; |
| 25 expected_headers[":method"] = "GET"; |
| 26 | 26 |
| 27 EXPECT_EQ(expected_headers, spdy_headers); | 27 EXPECT_EQ(expected_headers, spdy_headers); |
| 28 } | 28 } |
| 29 | 29 |
| 30 TEST(SpdyBalsaUtilsTest, ResponseHeadersToSpdyHeaders) { | 30 TEST(SpdyBalsaUtilsTest, ResponseHeadersToSpdyHeaders) { |
| 31 BalsaHeaders response_headers; | 31 BalsaHeaders response_headers; |
| 32 response_headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", | 32 response_headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", |
| 33 "OK"); | 33 "OK"); |
| 34 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::ResponseHeadersToSpdyHeaders( | 34 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::ResponseHeadersToSpdyHeaders( |
| 35 response_headers, kSupportedQuicVersions[0]); | 35 response_headers, kSupportedQuicVersions[0]); |
| 36 | 36 |
| 37 SpdyHeaderBlock expected_headers; | 37 SpdyHeaderBlock expected_headers; |
| 38 expected_headers[":status"] = "200"; | 38 expected_headers[":status"] = "200"; |
| 39 | 39 |
| 40 EXPECT_EQ(expected_headers, spdy_headers); | 40 EXPECT_EQ(expected_headers, spdy_headers); |
| 41 } | 41 } |
| 42 | 42 |
| 43 TEST(SpdyBalsaUtilsTest, SpdyHeadersToRequestHeaders) { | 43 TEST(SpdyBalsaUtilsTest, SpdyHeadersToRequestHeaders) { |
| 44 // Test :authority header. | 44 // Test :authority header. |
| 45 SpdyHeaderBlock spdy_headers; | 45 SpdyHeaderBlock spdy_headers; |
| 46 spdy_headers[":authority"] = "www.google.com"; | 46 spdy_headers[":authority"] = "www.google.com"; |
| 47 spdy_headers[":method"] = "GET"; | |
| 48 spdy_headers[":path"] = "/foo"; | 47 spdy_headers[":path"] = "/foo"; |
| 49 spdy_headers[":scheme"] = "https"; | 48 spdy_headers[":scheme"] = "https"; |
| 49 spdy_headers[":method"] = "GET"; |
| 50 | 50 |
| 51 BalsaHeaders request_headers; | 51 BalsaHeaders request_headers; |
| 52 SpdyBalsaUtils::SpdyHeadersToRequestHeaders(spdy_headers, &request_headers, | 52 SpdyBalsaUtils::SpdyHeadersToRequestHeaders(spdy_headers, &request_headers, |
| 53 kSupportedQuicVersions[0]); | 53 kSupportedQuicVersions[0]); |
| 54 EXPECT_EQ("GET", request_headers.request_method()); | 54 EXPECT_EQ("GET", request_headers.request_method()); |
| 55 EXPECT_EQ("HTTP/1.1", request_headers.request_version()); | 55 EXPECT_EQ("HTTP/1.1", request_headers.request_version()); |
| 56 EXPECT_EQ("/foo", request_headers.request_uri()); | 56 EXPECT_EQ("/foo", request_headers.request_uri()); |
| 57 EXPECT_EQ("www.google.com", request_headers.GetHeader("host")); | 57 EXPECT_EQ("www.google.com", request_headers.GetHeader("host")); |
| 58 | 58 |
| 59 // Test :host header (and no GET). | 59 // Test :host header (and no GET). |
| (...skipping 18 matching lines...) Expand all Loading... |
| 78 BalsaHeaders response_headers; | 78 BalsaHeaders response_headers; |
| 79 SpdyBalsaUtils::SpdyHeadersToResponseHeaders(spdy_headers, &response_headers, | 79 SpdyBalsaUtils::SpdyHeadersToResponseHeaders(spdy_headers, &response_headers, |
| 80 kSupportedQuicVersions[0]); | 80 kSupportedQuicVersions[0]); |
| 81 EXPECT_EQ("200", response_headers.response_code()); | 81 EXPECT_EQ("200", response_headers.response_code()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 } // namespace test | 85 } // namespace test |
| 86 } // namespace tools | 86 } // namespace tools |
| 87 } // namespace net | 87 } // namespace net |
| OLD | NEW |