Remove spdy_server_push_utils. PiperOrigin-RevId: 572964168
diff --git a/build/source_list.bzl b/build/source_list.bzl index b0541b3..3fae501 100644 --- a/build/source_list.bzl +++ b/build/source_list.bzl
@@ -232,7 +232,6 @@ "quic/core/http/quic_spdy_session.h", "quic/core/http/quic_spdy_stream.h", "quic/core/http/quic_spdy_stream_body_manager.h", - "quic/core/http/spdy_server_push_utils.h", "quic/core/http/spdy_utils.h", "quic/core/http/web_transport_http3.h", "quic/core/http/web_transport_stream_adapter.h", @@ -570,7 +569,6 @@ "quic/core/http/quic_spdy_session.cc", "quic/core/http/quic_spdy_stream.cc", "quic/core/http/quic_spdy_stream_body_manager.cc", - "quic/core/http/spdy_server_push_utils.cc", "quic/core/http/spdy_utils.cc", "quic/core/http/web_transport_http3.cc", "quic/core/http/web_transport_stream_adapter.cc", @@ -1189,7 +1187,6 @@ "quic/core/http/quic_spdy_session_test.cc", "quic/core/http/quic_spdy_stream_body_manager_test.cc", "quic/core/http/quic_spdy_stream_test.cc", - "quic/core/http/spdy_server_push_utils_test.cc", "quic/core/http/spdy_utils_test.cc", "quic/core/http/web_transport_http3_test.cc", "quic/core/legacy_quic_stream_id_manager_test.cc",
diff --git a/build/source_list.gni b/build/source_list.gni index 6745133..833203c 100644 --- a/build/source_list.gni +++ b/build/source_list.gni
@@ -232,7 +232,6 @@ "src/quiche/quic/core/http/quic_spdy_session.h", "src/quiche/quic/core/http/quic_spdy_stream.h", "src/quiche/quic/core/http/quic_spdy_stream_body_manager.h", - "src/quiche/quic/core/http/spdy_server_push_utils.h", "src/quiche/quic/core/http/spdy_utils.h", "src/quiche/quic/core/http/web_transport_http3.h", "src/quiche/quic/core/http/web_transport_stream_adapter.h", @@ -570,7 +569,6 @@ "src/quiche/quic/core/http/quic_spdy_session.cc", "src/quiche/quic/core/http/quic_spdy_stream.cc", "src/quiche/quic/core/http/quic_spdy_stream_body_manager.cc", - "src/quiche/quic/core/http/spdy_server_push_utils.cc", "src/quiche/quic/core/http/spdy_utils.cc", "src/quiche/quic/core/http/web_transport_http3.cc", "src/quiche/quic/core/http/web_transport_stream_adapter.cc", @@ -1190,7 +1188,6 @@ "src/quiche/quic/core/http/quic_spdy_session_test.cc", "src/quiche/quic/core/http/quic_spdy_stream_body_manager_test.cc", "src/quiche/quic/core/http/quic_spdy_stream_test.cc", - "src/quiche/quic/core/http/spdy_server_push_utils_test.cc", "src/quiche/quic/core/http/spdy_utils_test.cc", "src/quiche/quic/core/http/web_transport_http3_test.cc", "src/quiche/quic/core/legacy_quic_stream_id_manager_test.cc",
diff --git a/build/source_list.json b/build/source_list.json index 0796cd6..768b0b6 100644 --- a/build/source_list.json +++ b/build/source_list.json
@@ -231,7 +231,6 @@ "quiche/quic/core/http/quic_spdy_session.h", "quiche/quic/core/http/quic_spdy_stream.h", "quiche/quic/core/http/quic_spdy_stream_body_manager.h", - "quiche/quic/core/http/spdy_server_push_utils.h", "quiche/quic/core/http/spdy_utils.h", "quiche/quic/core/http/web_transport_http3.h", "quiche/quic/core/http/web_transport_stream_adapter.h", @@ -569,7 +568,6 @@ "quiche/quic/core/http/quic_spdy_session.cc", "quiche/quic/core/http/quic_spdy_stream.cc", "quiche/quic/core/http/quic_spdy_stream_body_manager.cc", - "quiche/quic/core/http/spdy_server_push_utils.cc", "quiche/quic/core/http/spdy_utils.cc", "quiche/quic/core/http/web_transport_http3.cc", "quiche/quic/core/http/web_transport_stream_adapter.cc", @@ -1189,7 +1187,6 @@ "quiche/quic/core/http/quic_spdy_session_test.cc", "quiche/quic/core/http/quic_spdy_stream_body_manager_test.cc", "quiche/quic/core/http/quic_spdy_stream_test.cc", - "quiche/quic/core/http/spdy_server_push_utils_test.cc", "quiche/quic/core/http/spdy_utils_test.cc", "quiche/quic/core/http/web_transport_http3_test.cc", "quiche/quic/core/legacy_quic_stream_id_manager_test.cc",
diff --git a/quiche/quic/core/http/quic_spdy_client_session_base.cc b/quiche/quic/core/http/quic_spdy_client_session_base.cc index fa941d6..db4d82a 100644 --- a/quiche/quic/core/http/quic_spdy_client_session_base.cc +++ b/quiche/quic/core/http/quic_spdy_client_session_base.cc
@@ -6,7 +6,6 @@ #include <string> -#include "quiche/quic/core/http/spdy_server_push_utils.h" #include "quiche/quic/core/quic_utils.h" #include "quiche/quic/platform/api/quic_flags.h" #include "quiche/quic/platform/api/quic_logging.h"
diff --git a/quiche/quic/core/http/quic_spdy_client_session_test.cc b/quiche/quic/core/http/quic_spdy_client_session_test.cc index 2c93bc9..59e1ed3 100644 --- a/quiche/quic/core/http/quic_spdy_client_session_test.cc +++ b/quiche/quic/core/http/quic_spdy_client_session_test.cc
@@ -18,7 +18,6 @@ #include "quiche/quic/core/http/http_constants.h" #include "quiche/quic/core/http/http_frames.h" #include "quiche/quic/core/http/quic_spdy_client_stream.h" -#include "quiche/quic/core/http/spdy_server_push_utils.h" #include "quiche/quic/core/quic_constants.h" #include "quiche/quic/core/quic_error_codes.h" #include "quiche/quic/core/quic_utils.h"
diff --git a/quiche/quic/core/http/spdy_server_push_utils.cc b/quiche/quic/core/http/spdy_server_push_utils.cc deleted file mode 100644 index 22dc13f..0000000 --- a/quiche/quic/core/http/spdy_server_push_utils.cc +++ /dev/null
@@ -1,215 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "quiche/quic/core/http/spdy_server_push_utils.h" - -#include "absl/strings/string_view.h" -#include "url/gurl.h" - -using spdy::Http2HeaderBlock; - -namespace quic { - -// static -std::string SpdyServerPushUtils::GetPromisedUrlFromHeaders( - const Http2HeaderBlock& headers) { - // RFC 7540, Section 8.1.2.3: All HTTP/2 requests MUST include exactly - // one valid value for the ":method", ":scheme", and ":path" pseudo-header - // fields, unless it is a CONNECT request. - - // RFC 7540, Section 8.2.1: The header fields in PUSH_PROMISE and any - // subsequent CONTINUATION frames MUST be a valid and complete set of request - // header fields (Section 8.1.2.3). The server MUST include a method in the - // ":method" pseudo-header field that is safe and cacheable. - // - // RFC 7231, Section 4.2.1: Of the request methods defined by this - // specification, the GET, HEAD, OPTIONS, and TRACE methods are defined to be - // safe. - // - // RFC 7231, Section 4.2.1: ... this specification defines GET, HEAD, and - // POST as cacheable, ... - // - // So the only methods allowed in a PUSH_PROMISE are GET and HEAD. - Http2HeaderBlock::const_iterator it = headers.find(":method"); - if (it == headers.end() || (it->second != "GET" && it->second != "HEAD")) { - return std::string(); - } - - it = headers.find(":scheme"); - if (it == headers.end() || it->second.empty()) { - return std::string(); - } - absl::string_view scheme = it->second; - - // RFC 7540, Section 8.2: The server MUST include a value in the - // ":authority" pseudo-header field for which the server is authoritative - // (see Section 10.1). - it = headers.find(":authority"); - if (it == headers.end() || it->second.empty()) { - return std::string(); - } - absl::string_view authority = it->second; - - // RFC 7540, Section 8.1.2.3 requires that the ":path" pseudo-header MUST - // NOT be empty for "http" or "https" URIs; - // - // However, to ensure the scheme is consistently canonicalized, that check - // is deferred to implementations in QuicUrlUtils::GetPushPromiseUrl(). - it = headers.find(":path"); - if (it == headers.end()) { - return std::string(); - } - absl::string_view path = it->second; - - return GetPushPromiseUrl(scheme, authority, path); -} - -// static -std::string SpdyServerPushUtils::GetPromisedHostNameFromHeaders( - const Http2HeaderBlock& headers) { - // TODO(fayang): Consider just checking out the value of the ":authority" key - // in headers. - return GURL(GetPromisedUrlFromHeaders(headers)).host(); -} - -// static -bool SpdyServerPushUtils::PromisedUrlIsValid(const Http2HeaderBlock& headers) { - std::string url(GetPromisedUrlFromHeaders(headers)); - return !url.empty() && GURL(url).is_valid(); -} - -// static -std::string SpdyServerPushUtils::GetPushPromiseUrl(absl::string_view scheme, - absl::string_view authority, - absl::string_view path) { - // RFC 7540, Section 8.1.2.3: The ":path" pseudo-header field includes the - // path and query parts of the target URI (the "path-absolute" production - // and optionally a '?' character followed by the "query" production (see - // Sections 3.3 and 3.4 of RFC3986). A request in asterisk form includes the - // value '*' for the ":path" pseudo-header field. - // - // This pseudo-header field MUST NOT be empty for "http" or "https" URIs; - // "http" or "https" URIs that do not contain a path MUST include a value of - // '/'. The exception to this rule is an OPTIONS request for an "http" or - // "https" URI that does not include a path component; these MUST include a - // ":path" pseudo-header with a value of '*' (see RFC7230, Section 5.3.4). - // - // In addition to the above restriction from RFC 7540, note that RFC3986 - // defines the "path-absolute" construction as starting with "/" but not "//". - // - // RFC 7540, Section 8.2.1: The header fields in PUSH_PROMISE and any - // subsequent CONTINUATION frames MUST be a valid and complete set of request - // header fields (Section 8.1.2.3). The server MUST include a method in the - // ":method" pseudo-header field that is safe and cacheable. - // - // RFC 7231, Section 4.2.1: - // ... this specification defines GET, HEAD, and POST as cacheable, ... - // - // Since the OPTIONS method is not cacheable, it cannot be the method of a - // PUSH_PROMISE. Therefore, the exception mentioned in RFC 7540, Section - // 8.1.2.3 about OPTIONS requests does not apply here (i.e. ":path" cannot be - // "*"). - if (path.empty() || path[0] != '/' || (path.size() >= 2 && path[1] == '/')) { - return std::string(); - } - - // Validate the scheme; this is to ensure a scheme of "foo://bar" is not - // parsed as a URL of "foo://bar://baz" when combined with a host of "baz". - std::string canonical_scheme; - url::StdStringCanonOutput canon_scheme_output(&canonical_scheme); - url::Component canon_component; - url::Component scheme_component(0, scheme.size()); - - if (!url::CanonicalizeScheme(scheme.data(), scheme_component, - &canon_scheme_output, &canon_component) || - !canon_component.is_nonempty() || canon_component.begin != 0) { - return std::string(); - } - canonical_scheme.resize(canon_component.len + 1); - - // Validate the authority; this is to ensure an authority such as - // "host/path" is not accepted, as when combined with a scheme like - // "http://", could result in a URL of "http://host/path". - url::Component auth_component(0, authority.size()); - url::Component username_component; - url::Component password_component; - url::Component host_component; - url::Component port_component; - - url::ParseAuthority(authority.data(), auth_component, &username_component, - &password_component, &host_component, &port_component); - - // RFC 7540, Section 8.1.2.3: The authority MUST NOT include the deprecated - // "userinfo" subcomponent for "http" or "https" schemed URIs. - // - // Note: Although |canonical_scheme| has not yet been checked for that, as - // it is performed later in processing, only "http" and "https" schemed - // URIs are supported for PUSH. - if (username_component.is_valid() || password_component.is_valid()) { - return std::string(); - } - - // Failed parsing or no host present. ParseAuthority() will ensure that - // host_component + port_component cover the entire string, if - // username_component and password_component are not present. - if (!host_component.is_nonempty()) { - return std::string(); - } - - // Validate the port (if present; it's optional). - int parsed_port_number = url::PORT_INVALID; - if (port_component.is_nonempty()) { - parsed_port_number = url::ParsePort(authority.data(), port_component); - if (parsed_port_number < 0 && parsed_port_number != url::PORT_UNSPECIFIED) { - return std::string(); - } - } - - // Validate the host by attempting to canonicalize it. Invalid characters - // will result in a canonicalization failure (e.g. '/') - std::string canon_host; - url::StdStringCanonOutput canon_host_output(&canon_host); - canon_component.reset(); - if (!url::CanonicalizeHost(authority.data(), host_component, - &canon_host_output, &canon_component) || - !canon_component.is_nonempty() || canon_component.begin != 0) { - return std::string(); - } - - // At this point, "authority" has been validated to either be of the form - // 'host:port' or 'host', with 'host' being a valid domain or IP address, - // and 'port' (if present), being a valid port. Attempt to construct a - // URL of just the (scheme, host, port), which should be safe and will not - // result in ambiguous parsing. - // - // This also enforces that all PUSHed URLs are either HTTP or HTTPS-schemed - // URIs, consistent with the other restrictions enforced above. - // - // Note: url::CanonicalizeScheme() will have added the ':' to - // |canonical_scheme|. - GURL origin_url(canonical_scheme + "//" + std::string(authority)); - if (!origin_url.is_valid() || !origin_url.SchemeIsHTTPOrHTTPS() || - // The following checks are merely defense in depth. - origin_url.has_username() || origin_url.has_password() || - (origin_url.has_path() && origin_url.path_piece() != "/") || - origin_url.has_query() || origin_url.has_ref()) { - return std::string(); - } - - // Attempt to parse the path. - std::string spec = origin_url.GetWithEmptyPath().spec(); - spec.pop_back(); // Remove the '/', as ":path" must contain it. - spec.append(std::string(path)); - - // Attempt to parse the full URL, with the path as well. Ensure there is no - // fragment to the query. - GURL full_url(spec); - if (!full_url.is_valid() || full_url.has_ref()) { - return std::string(); - } - - return full_url.spec(); -} - -} // namespace quic
diff --git a/quiche/quic/core/http/spdy_server_push_utils.h b/quiche/quic/core/http/spdy_server_push_utils.h deleted file mode 100644 index 82166cd..0000000 --- a/quiche/quic/core/http/spdy_server_push_utils.h +++ /dev/null
@@ -1,43 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_ -#define QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_ - -#include "absl/strings/string_view.h" -#include "quiche/quic/platform/api/quic_export.h" -#include "quiche/spdy/core/http2_header_block.h" - -namespace quic { - -class QUICHE_EXPORT SpdyServerPushUtils { - public: - SpdyServerPushUtils() = delete; - - // Returns a canonicalized URL composed from the :scheme, :authority, and - // :path headers of a PUSH_PROMISE. Returns empty string if the headers do not - // conform to HTTP/2 spec or if the ":method" header contains a forbidden - // method for PUSH_PROMISE. - static std::string GetPromisedUrlFromHeaders( - const spdy::Http2HeaderBlock& headers); - - // Returns hostname, or empty string if missing. - static std::string GetPromisedHostNameFromHeaders( - const spdy::Http2HeaderBlock& headers); - - // Returns true if result of |GetPromisedUrlFromHeaders()| is non-empty - // and is a well-formed URL. - static bool PromisedUrlIsValid(const spdy::Http2HeaderBlock& headers); - - // Returns a canonical, valid URL for a PUSH_PROMISE with the specified - // ":scheme", ":authority", and ":path" header fields, or an empty - // string if the resulting URL is not valid or supported. - static std::string GetPushPromiseUrl(absl::string_view scheme, - absl::string_view authority, - absl::string_view path); -}; - -} // namespace quic - -#endif // QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_
diff --git a/quiche/quic/core/http/spdy_server_push_utils_test.cc b/quiche/quic/core/http/spdy_server_push_utils_test.cc deleted file mode 100644 index cffa915..0000000 --- a/quiche/quic/core/http/spdy_server_push_utils_test.cc +++ /dev/null
@@ -1,222 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "quiche/quic/core/http/spdy_server_push_utils.h" - -#include <memory> -#include <string> -#include <vector> - -#include "absl/base/macros.h" -#include "quiche/quic/platform/api/quic_test.h" -#include "quiche/common/test_tools/quiche_test_utils.h" - -using spdy::Http2HeaderBlock; - -namespace quic { -namespace test { - -using GetPromisedUrlFromHeaders = QuicTest; - -TEST_F(GetPromisedUrlFromHeaders, Basic) { - Http2HeaderBlock headers; - headers[":method"] = "GET"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), ""); - headers[":scheme"] = "https"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), ""); - headers[":authority"] = "www.google.com"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), ""); - headers[":path"] = "/index.html"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), - "https://www.google.com/index.html"); - headers["key1"] = "value1"; - headers["key2"] = "value2"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), - "https://www.google.com/index.html"); -} - -TEST_F(GetPromisedUrlFromHeaders, Connect) { - Http2HeaderBlock headers; - headers[":method"] = "CONNECT"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), ""); - headers[":authority"] = "www.google.com"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), ""); - headers[":scheme"] = "https"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), ""); - headers[":path"] = "https"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), ""); -} - -TEST_F(GetPromisedUrlFromHeaders, InvalidUserinfo) { - Http2HeaderBlock headers; - headers[":method"] = "GET"; - headers[":authority"] = "user@www.google.com"; - headers[":scheme"] = "https"; - headers[":path"] = "/"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), ""); -} - -TEST_F(GetPromisedUrlFromHeaders, InvalidPath) { - Http2HeaderBlock headers; - headers[":method"] = "GET"; - headers[":authority"] = "www.google.com"; - headers[":scheme"] = "https"; - headers[":path"] = ""; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers), ""); -} - -using GetPromisedHostNameFromHeaders = QuicTest; - -TEST_F(GetPromisedHostNameFromHeaders, NormalUsage) { - Http2HeaderBlock headers; - headers[":method"] = "GET"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedHostNameFromHeaders(headers), ""); - headers[":scheme"] = "https"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedHostNameFromHeaders(headers), ""); - headers[":authority"] = "www.google.com"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedHostNameFromHeaders(headers), ""); - headers[":path"] = "/index.html"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedHostNameFromHeaders(headers), - "www.google.com"); - headers["key1"] = "value1"; - headers["key2"] = "value2"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedHostNameFromHeaders(headers), - "www.google.com"); - headers[":authority"] = "www.google.com:6666"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedHostNameFromHeaders(headers), - "www.google.com"); - headers[":authority"] = "192.168.1.1"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedHostNameFromHeaders(headers), - "192.168.1.1"); - headers[":authority"] = "192.168.1.1:6666"; - EXPECT_EQ(SpdyServerPushUtils::GetPromisedHostNameFromHeaders(headers), - "192.168.1.1"); -} - -using PushPromiseUrlTest = QuicTest; - -TEST_F(PushPromiseUrlTest, GetPushPromiseUrl) { - // Test rejection of various inputs. - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl("file", "localhost", - "/etc/password")); - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl( - "file", "", "/C:/Windows/System32/Config/")); - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl( - "", "https://www.google.com", "/")); - - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl("https://www.google.com", - "www.google.com", "/")); - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl("https://", - "www.google.com", "/")); - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl("https", "", "/")); - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl("https", "", - "www.google.com/")); - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl("https", - "www.google.com/", "/")); - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl("https", - "www.google.com", "")); - EXPECT_EQ("", SpdyServerPushUtils::GetPushPromiseUrl("https", "www.google", - ".com/")); - - // Test acception/rejection of various input combinations. - // |input_headers| is an array of pairs. The first value of each pair is a - // string that will be used as one of the inputs of GetPushPromiseUrl(). The - // second value of each pair is a bitfield where the lowest 3 bits indicate - // for which headers that string is valid (in a PUSH_PROMISE). For example, - // the string "http" would be valid for both the ":scheme" and ":authority" - // headers, so the bitfield paired with it is set to SCHEME | AUTH. - const unsigned char SCHEME = (1u << 0); - const unsigned char AUTH = (1u << 1); - const unsigned char PATH = (1u << 2); - std::vector<std::pair<const char*, unsigned char>> input_headers = { - {"http", SCHEME | AUTH}, - {"https", SCHEME | AUTH}, - {"hTtP", SCHEME | AUTH}, - {"HTTPS", SCHEME | AUTH}, - {"www.google.com", AUTH}, - {"90af90e0", AUTH}, - {"12foo%20-bar:00001233", AUTH}, - {"192.168.0.5", AUTH}, - // Comment out temporarily. See https://crrev.com/c/4685220 for details. - // {"[::ffff:192.168.0.1.]", AUTH}, - {"http:", AUTH}, - {"bife l", AUTH}, - {"/", PATH}, - {"/foo/bar/baz", PATH}, - {"/%20-2DVdkj.cie/foe_.iif/", PATH}, - {"http://", 0}, - {":443", 0}, - {":80/eddd", 0}, - {"google.com:-0", 0}, - {"google.com:65536", 0}, - {"http://google.com", 0}, - {"http://google.com:39", 0}, - {"//google.com/foo", 0}, - {".com/", 0}, - {"http://www.google.com/", 0}, - {"http://foo:439", 0}, - {"[::ffff:192.168", 0}, - {"]/", 0}, - {"//", 0}}; - if (quiche::test::GoogleUrlSupportsIdnaForTest()) { - input_headers.push_back({"GOO\u200b\u2060\ufeffgoo", AUTH}); - } - for (size_t i = 0; i < input_headers.size(); ++i) { - bool should_accept = (input_headers[i].second & SCHEME); - for (size_t j = 0; j < input_headers.size(); ++j) { - bool should_accept_2 = should_accept && (input_headers[j].second & AUTH); - for (size_t k = 0; k < input_headers.size(); ++k) { - // |should_accept_3| indicates whether or not GetPushPromiseUrl() is - // expected to accept this input combination. - bool should_accept_3 = - should_accept_2 && (input_headers[k].second & PATH); - - std::string url = SpdyServerPushUtils::GetPushPromiseUrl( - input_headers[i].first, input_headers[j].first, - input_headers[k].first); - - ::testing::AssertionResult result = ::testing::AssertionSuccess(); - if (url.empty() == should_accept_3) { - result = ::testing::AssertionFailure() - << "GetPushPromiseUrl() accepted/rejected the inputs when " - "it shouldn't have." - << std::endl - << " scheme: " << input_headers[i].first << std::endl - << " authority: " << input_headers[j].first << std::endl - << " path: " << input_headers[k].first << std::endl - << "Output: " << url << std::endl; - } - ASSERT_TRUE(result); - } - } - } - - // Test canonicalization of various valid inputs. - EXPECT_EQ("http://www.google.com/", SpdyServerPushUtils::GetPushPromiseUrl( - "http", "www.google.com", "/")); - EXPECT_EQ("https://www.goo-gle.com/fOOo/baRR", - SpdyServerPushUtils::GetPushPromiseUrl("hTtPs", "wWw.gOo-gLE.cOm", - "/fOOo/baRR")); - EXPECT_EQ("https://www.goo-gle.com:3278/pAth/To/reSOurce", - SpdyServerPushUtils::GetPushPromiseUrl( - "hTtPs", "Www.gOo-Gle.Com:000003278", "/pAth/To/reSOurce")); - EXPECT_EQ("https://foo%20bar/foo/bar/baz", - SpdyServerPushUtils::GetPushPromiseUrl("https", "foo bar", - "/foo/bar/baz")); - EXPECT_EQ("http://foo.com:70/e/", SpdyServerPushUtils::GetPushPromiseUrl( - "http", "foo.com:0000070", "/e/")); - EXPECT_EQ("http://192.168.0.1:70/e/", - SpdyServerPushUtils::GetPushPromiseUrl( - "http", "0300.0250.00.01:0070", "/e/")); - EXPECT_EQ("http://192.168.0.1/e/", SpdyServerPushUtils::GetPushPromiseUrl( - "http", "0xC0a80001", "/e/")); - EXPECT_EQ("http://[::c0a8:1]/", SpdyServerPushUtils::GetPushPromiseUrl( - "http", "[::192.168.0.1]", "/")); - EXPECT_EQ("https://[::ffff:c0a8:1]/", - SpdyServerPushUtils::GetPushPromiseUrl( - "https", "[::ffff:0xC0.0Xa8.0x0.0x1]", "/")); -} - -} // namespace test -} // namespace quic