blob: 99a834bd695d9464a40e70f6598e57882391a7cf [file] [log] [blame]
danzh2a930462019-07-03 07:28:06 -07001// 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
vasilvve2707e32020-10-08 12:27:46 -07008#include "absl/strings/string_view.h"
danzh2a930462019-07-03 07:28:06 -07009#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
danzh2a930462019-07-03 07:28:06 -070010#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h"
11
12namespace quic {
13
14class 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.
vasilvve2707e32020-10-08 12:27:46 -070036 static std::string GetPushPromiseUrl(absl::string_view scheme,
37 absl::string_view authority,
38 absl::string_view path);
danzh2a930462019-07-03 07:28:06 -070039};
40
41} // namespace quic
42
43#endif // QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_