1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_ 6 #define QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_ 7 8 #include "absl/strings/string_view.h" 9 #include "quiche/quic/platform/api/quic_export.h" 10 #include "quiche/spdy/core/http2_header_block.h" 11 12 namespace quic { 13 14 class QUIC_EXPORT_PRIVATE SpdyServerPushUtils { 15 public: 16 SpdyServerPushUtils() = delete; 17 18 // Returns a canonicalized URL composed from the :scheme, :authority, and 19 // :path headers of a PUSH_PROMISE. Returns empty string if the headers do not 20 // conform to HTTP/2 spec or if the ":method" header contains a forbidden 21 // method for PUSH_PROMISE. 22 static std::string GetPromisedUrlFromHeaders( 23 const spdy::Http2HeaderBlock& headers); 24 25 // Returns hostname, or empty string if missing. 26 static std::string GetPromisedHostNameFromHeaders( 27 const spdy::Http2HeaderBlock& headers); 28 29 // Returns true if result of |GetPromisedUrlFromHeaders()| is non-empty 30 // and is a well-formed URL. 31 static bool PromisedUrlIsValid(const spdy::Http2HeaderBlock& headers); 32 33 // Returns a canonical, valid URL for a PUSH_PROMISE with the specified 34 // ":scheme", ":authority", and ":path" header fields, or an empty 35 // string if the resulting URL is not valid or supported. 36 static std::string GetPushPromiseUrl(absl::string_view scheme, 37 absl::string_view authority, 38 absl::string_view path); 39 }; 40 41 } // namespace quic 42 43 #endif // QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_ 44