OLD | NEW |
(Empty) | |
| 1 // 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 |
| 5 #include "net/http2/http2_constants_test_util.h" |
| 6 |
| 7 namespace net { |
| 8 namespace test { |
| 9 |
| 10 std::vector<Http2FrameType> AllHttp2FrameTypes() { |
| 11 // clang-format off |
| 12 return { |
| 13 Http2FrameType::DATA, |
| 14 Http2FrameType::HEADERS, |
| 15 Http2FrameType::PRIORITY, |
| 16 Http2FrameType::RST_STREAM, |
| 17 Http2FrameType::SETTINGS, |
| 18 Http2FrameType::PUSH_PROMISE, |
| 19 Http2FrameType::PING, |
| 20 Http2FrameType::GOAWAY, |
| 21 Http2FrameType::WINDOW_UPDATE, |
| 22 Http2FrameType::CONTINUATION, |
| 23 Http2FrameType::ALTSVC, |
| 24 }; |
| 25 // clang-format on |
| 26 } |
| 27 |
| 28 std::vector<Http2FrameFlag> AllHttp2FrameFlagsForFrameType( |
| 29 Http2FrameType type) { |
| 30 // clang-format off |
| 31 switch (type) { |
| 32 case Http2FrameType::DATA: |
| 33 return { |
| 34 Http2FrameFlag::FLAG_END_STREAM, |
| 35 Http2FrameFlag::FLAG_PADDED, |
| 36 }; |
| 37 case Http2FrameType::HEADERS: |
| 38 return { |
| 39 Http2FrameFlag::FLAG_END_STREAM, |
| 40 Http2FrameFlag::FLAG_END_HEADERS, |
| 41 Http2FrameFlag::FLAG_PADDED, |
| 42 Http2FrameFlag::FLAG_PRIORITY, |
| 43 }; |
| 44 case Http2FrameType::SETTINGS: |
| 45 return { |
| 46 Http2FrameFlag::FLAG_ACK, |
| 47 }; |
| 48 case Http2FrameType::PUSH_PROMISE: |
| 49 return { |
| 50 Http2FrameFlag::FLAG_END_HEADERS, |
| 51 Http2FrameFlag::FLAG_PADDED, |
| 52 }; |
| 53 case Http2FrameType::PING: |
| 54 return { |
| 55 Http2FrameFlag::FLAG_ACK, |
| 56 }; |
| 57 case Http2FrameType::CONTINUATION: |
| 58 return { |
| 59 Http2FrameFlag::FLAG_END_HEADERS, |
| 60 }; |
| 61 default: |
| 62 return std::vector<Http2FrameFlag>{}; |
| 63 } |
| 64 // clang-format on |
| 65 } |
| 66 |
| 67 std::vector<Http2ErrorCode> AllHttp2ErrorCodes() { |
| 68 // clang-format off |
| 69 return { |
| 70 Http2ErrorCode::HTTP2_NO_ERROR, |
| 71 Http2ErrorCode::PROTOCOL_ERROR, |
| 72 Http2ErrorCode::INTERNAL_ERROR, |
| 73 Http2ErrorCode::FLOW_CONTROL_ERROR, |
| 74 Http2ErrorCode::SETTINGS_TIMEOUT, |
| 75 Http2ErrorCode::STREAM_CLOSED, |
| 76 Http2ErrorCode::FRAME_SIZE_ERROR, |
| 77 Http2ErrorCode::REFUSED_STREAM, |
| 78 Http2ErrorCode::CANCEL, |
| 79 Http2ErrorCode::COMPRESSION_ERROR, |
| 80 Http2ErrorCode::CONNECT_ERROR, |
| 81 Http2ErrorCode::ENHANCE_YOUR_CALM, |
| 82 Http2ErrorCode::INADEQUATE_SECURITY, |
| 83 Http2ErrorCode::HTTP_1_1_REQUIRED, |
| 84 }; |
| 85 // clang-format on |
| 86 } |
| 87 |
| 88 std::vector<Http2SettingsParameter> AllHttp2SettingsParameters() { |
| 89 // clang-format off |
| 90 return { |
| 91 Http2SettingsParameter::HEADER_TABLE_SIZE, |
| 92 Http2SettingsParameter::ENABLE_PUSH, |
| 93 Http2SettingsParameter::MAX_CONCURRENT_STREAMS, |
| 94 Http2SettingsParameter::INITIAL_WINDOW_SIZE, |
| 95 Http2SettingsParameter::MAX_FRAME_SIZE, |
| 96 Http2SettingsParameter::MAX_HEADER_LIST_SIZE, |
| 97 }; |
| 98 // clang-format on |
| 99 } |
| 100 |
| 101 // Returns a mask of flags supported for the specified frame type. Returns |
| 102 // zero for unknown frame types. |
| 103 uint8_t KnownFlagsMaskForFrameType(Http2FrameType type) { |
| 104 switch (type) { |
| 105 case Http2FrameType::DATA: |
| 106 return Http2FrameFlag::FLAG_END_STREAM | Http2FrameFlag::FLAG_PADDED; |
| 107 case Http2FrameType::HEADERS: |
| 108 return Http2FrameFlag::FLAG_END_STREAM | |
| 109 Http2FrameFlag::FLAG_END_HEADERS | Http2FrameFlag::FLAG_PADDED | |
| 110 Http2FrameFlag::FLAG_PRIORITY; |
| 111 case Http2FrameType::PRIORITY: |
| 112 return 0x00; |
| 113 case Http2FrameType::RST_STREAM: |
| 114 return 0x00; |
| 115 case Http2FrameType::SETTINGS: |
| 116 return Http2FrameFlag::FLAG_ACK; |
| 117 case Http2FrameType::PUSH_PROMISE: |
| 118 return Http2FrameFlag::FLAG_END_HEADERS | Http2FrameFlag::FLAG_PADDED; |
| 119 case Http2FrameType::PING: |
| 120 return Http2FrameFlag::FLAG_ACK; |
| 121 case Http2FrameType::GOAWAY: |
| 122 return 0x00; |
| 123 case Http2FrameType::WINDOW_UPDATE: |
| 124 return 0x00; |
| 125 case Http2FrameType::CONTINUATION: |
| 126 return Http2FrameFlag::FLAG_END_HEADERS; |
| 127 case Http2FrameType::ALTSVC: |
| 128 return 0x00; |
| 129 default: |
| 130 return 0x00; |
| 131 } |
| 132 } |
| 133 |
| 134 uint8_t InvalidFlagMaskForFrameType(Http2FrameType type) { |
| 135 if (IsSupportedHttp2FrameType(type)) { |
| 136 return ~KnownFlagsMaskForFrameType(type); |
| 137 } |
| 138 return 0x00; |
| 139 } |
| 140 |
| 141 } // namespace test |
| 142 } // namespace net |
OLD | NEW |