blob: 0734ffb7afeac60bd2b6a0c01916cd851ae1338d [file] [log] [blame]
QUICHE teamfd50a402018-12-07 22:54:05 -05001// Copyright 2016 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
QUICHE team5be974e2020-12-29 18:35:24 -05005#include "http2/http2_constants_test_util.h"
QUICHE teamfd50a402018-12-07 22:54:05 -05006
7namespace http2 {
8namespace test {
9
10std::vector<Http2ErrorCode> AllHttp2ErrorCodes() {
11 // clang-format off
12 return {
13 Http2ErrorCode::HTTP2_NO_ERROR,
14 Http2ErrorCode::PROTOCOL_ERROR,
15 Http2ErrorCode::INTERNAL_ERROR,
16 Http2ErrorCode::FLOW_CONTROL_ERROR,
17 Http2ErrorCode::SETTINGS_TIMEOUT,
18 Http2ErrorCode::STREAM_CLOSED,
19 Http2ErrorCode::FRAME_SIZE_ERROR,
20 Http2ErrorCode::REFUSED_STREAM,
21 Http2ErrorCode::CANCEL,
22 Http2ErrorCode::COMPRESSION_ERROR,
23 Http2ErrorCode::CONNECT_ERROR,
24 Http2ErrorCode::ENHANCE_YOUR_CALM,
25 Http2ErrorCode::INADEQUATE_SECURITY,
26 Http2ErrorCode::HTTP_1_1_REQUIRED,
27 };
28 // clang-format on
29}
30
31std::vector<Http2SettingsParameter> AllHttp2SettingsParameters() {
32 // clang-format off
33 return {
34 Http2SettingsParameter::HEADER_TABLE_SIZE,
35 Http2SettingsParameter::ENABLE_PUSH,
36 Http2SettingsParameter::MAX_CONCURRENT_STREAMS,
37 Http2SettingsParameter::INITIAL_WINDOW_SIZE,
38 Http2SettingsParameter::MAX_FRAME_SIZE,
39 Http2SettingsParameter::MAX_HEADER_LIST_SIZE,
40 };
41 // clang-format on
42}
43
44// Returns a mask of flags supported for the specified frame type. Returns
45// zero for unknown frame types.
46uint8_t KnownFlagsMaskForFrameType(Http2FrameType type) {
47 switch (type) {
48 case Http2FrameType::DATA:
49 return Http2FrameFlag::END_STREAM | Http2FrameFlag::PADDED;
50 case Http2FrameType::HEADERS:
51 return Http2FrameFlag::END_STREAM | Http2FrameFlag::END_HEADERS |
52 Http2FrameFlag::PADDED | Http2FrameFlag::PRIORITY;
53 case Http2FrameType::PRIORITY:
54 return 0x00;
55 case Http2FrameType::RST_STREAM:
56 return 0x00;
57 case Http2FrameType::SETTINGS:
58 return Http2FrameFlag::ACK;
59 case Http2FrameType::PUSH_PROMISE:
60 return Http2FrameFlag::END_HEADERS | Http2FrameFlag::PADDED;
61 case Http2FrameType::PING:
62 return Http2FrameFlag::ACK;
63 case Http2FrameType::GOAWAY:
64 return 0x00;
65 case Http2FrameType::WINDOW_UPDATE:
66 return 0x00;
67 case Http2FrameType::CONTINUATION:
68 return Http2FrameFlag::END_HEADERS;
69 case Http2FrameType::ALTSVC:
70 return 0x00;
71 default:
72 return 0x00;
73 }
74}
75
76uint8_t InvalidFlagMaskForFrameType(Http2FrameType type) {
77 if (IsSupportedHttp2FrameType(type)) {
78 return ~KnownFlagsMaskForFrameType(type);
79 }
80 return 0x00;
81}
82
83} // namespace test
84} // namespace http2