danzh | 2a93046 | 2019-07-03 07:28:06 -0700 | [diff] [blame] | 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 | |
vasilvv | e2707e3 | 2020-10-08 12:27:46 -0700 | [diff] [blame] | 8 | #include "absl/strings/string_view.h" |
danzh | 2a93046 | 2019-07-03 07:28:06 -0700 | [diff] [blame] | 9 | #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" |
danzh | 2a93046 | 2019-07-03 07:28:06 -0700 | [diff] [blame] | 10 | #include "net/third_party/quiche/src/spdy/core/spdy_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::SpdyHeaderBlock& headers); |
| 24 | |
| 25 | // Returns hostname, or empty string if missing. |
| 26 | static std::string GetPromisedHostNameFromHeaders( |
| 27 | const spdy::SpdyHeaderBlock& 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::SpdyHeaderBlock& 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. |
vasilvv | e2707e3 | 2020-10-08 12:27:46 -0700 | [diff] [blame] | 36 | static std::string GetPushPromiseUrl(absl::string_view scheme, |
| 37 | absl::string_view authority, |
| 38 | absl::string_view path); |
danzh | 2a93046 | 2019-07-03 07:28:06 -0700 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | } // namespace quic |
| 42 | |
| 43 | #endif // QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_ |