QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [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_UTILS_H_ |
| 6 | #define QUICHE_QUIC_CORE_HTTP_SPDY_UTILS_H_ |
| 7 | |
| 8 | #include <cstddef> |
| 9 | #include <cstdint> |
vasilvv | 872e7a3 | 2019-03-12 16:42:44 -0700 | [diff] [blame] | 10 | #include <string> |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 11 | |
renjietang | 2db302b | 2019-09-23 12:40:17 -0700 | [diff] [blame] | 12 | #include "net/third_party/quiche/src/quic/core/http/http_constants.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 13 | #include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" |
| 14 | #include "net/third_party/quiche/src/quic/core/quic_packets.h" |
| 15 | #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" |
danzh | 2a93046 | 2019-07-03 07:28:06 -0700 | [diff] [blame] | 16 | #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 17 | |
| 18 | namespace quic { |
| 19 | |
| 20 | class QUIC_EXPORT_PRIVATE SpdyUtils { |
| 21 | public: |
| 22 | SpdyUtils() = delete; |
| 23 | |
| 24 | // Populate |content length| with the value of the content-length header. |
| 25 | // Returns true on success, false if parsing fails or content-length header is |
| 26 | // missing. |
| 27 | static bool ExtractContentLengthFromHeaders(int64_t* content_length, |
| 28 | spdy::SpdyHeaderBlock* headers); |
| 29 | |
| 30 | // Copies a list of headers to a SpdyHeaderBlock. |
| 31 | static bool CopyAndValidateHeaders(const QuicHeaderList& header_list, |
| 32 | int64_t* content_length, |
| 33 | spdy::SpdyHeaderBlock* headers); |
| 34 | |
| 35 | // Copies a list of headers to a SpdyHeaderBlock. |
bnc | 5231ee2 | 2019-04-15 19:02:13 -0700 | [diff] [blame] | 36 | // If |expect_final_byte_offset| is true, requires exactly one header field |
| 37 | // with key kFinalOffsetHeaderKey and an integer value. |
| 38 | // If |expect_final_byte_offset| is false, no kFinalOffsetHeaderKey may be |
| 39 | // present. |
| 40 | // Returns true if parsing is successful. Returns false if the presence of |
| 41 | // kFinalOffsetHeaderKey does not match the value of |
| 42 | // |expect_final_byte_offset|, the kFinalOffsetHeaderKey value cannot be |
| 43 | // parsed, any other pseudo-header is present, an empty header key is present, |
| 44 | // or a header key contains an uppercase character. |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 45 | static bool CopyAndValidateTrailers(const QuicHeaderList& header_list, |
bnc | 5231ee2 | 2019-04-15 19:02:13 -0700 | [diff] [blame] | 46 | bool expect_final_byte_offset, |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 47 | size_t* final_byte_offset, |
| 48 | spdy::SpdyHeaderBlock* trailers); |
| 49 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 50 | // Populates the fields of |headers| to make a GET request of |url|, |
| 51 | // which must be fully-qualified. |
vasilvv | c48c871 | 2019-03-11 13:38:16 -0700 | [diff] [blame] | 52 | static bool PopulateHeaderBlockFromUrl(const std::string url, |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 53 | spdy::SpdyHeaderBlock* headers); |
renjietang | 2db302b | 2019-09-23 12:40:17 -0700 | [diff] [blame] | 54 | |
| 55 | // Returns HTTP/3 SETTINGS identifier as a string. |
| 56 | static std::string H3SettingsToString( |
| 57 | Http3AndQpackSettingsIdentifiers identifier); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } // namespace quic |
| 61 | |
| 62 | #endif // QUICHE_QUIC_CORE_HTTP_SPDY_UTILS_H_ |