v / vlib / net / http / h2_error.v
43 lines · 41 sloc · 1.33 KB · 57badade8f66da0ba48442bccf5773ffae8bbd2c
Raw
1// Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved.
2// Use of this source code is governed by an MIT license
3// that can be found in the LICENSE file.
4module http
5
6// H2ErrorCode is an HTTP/2 error code, as used in RST_STREAM and GOAWAY
7// frames (RFC 7540 Section 7).
8pub enum H2ErrorCode as u32 {
9 no_error = 0x0
10 protocol_error = 0x1
11 internal_error = 0x2
12 flow_control_error = 0x3
13 settings_timeout = 0x4
14 stream_closed = 0x5
15 frame_size_error = 0x6
16 refused_stream = 0x7
17 cancel = 0x8
18 compression_error = 0x9
19 connect_error = 0xa
20 enhance_your_calm = 0xb
21 inadequate_security = 0xc
22 http_1_1_required = 0xd
23}
24
25// str returns the RFC name of the error code.
26pub fn (e H2ErrorCode) str() string {
27 return match e {
28 .no_error { 'NO_ERROR' }
29 .protocol_error { 'PROTOCOL_ERROR' }
30 .internal_error { 'INTERNAL_ERROR' }
31 .flow_control_error { 'FLOW_CONTROL_ERROR' }
32 .settings_timeout { 'SETTINGS_TIMEOUT' }
33 .stream_closed { 'STREAM_CLOSED' }
34 .frame_size_error { 'FRAME_SIZE_ERROR' }
35 .refused_stream { 'REFUSED_STREAM' }
36 .cancel { 'CANCEL' }
37 .compression_error { 'COMPRESSION_ERROR' }
38 .connect_error { 'CONNECT_ERROR' }
39 .enhance_your_calm { 'ENHANCE_YOUR_CALM' }
40 .inadequate_security { 'INADEQUATE_SECURITY' }
41 .http_1_1_required { 'HTTP_1_1_REQUIRED' }
42 }
43}
44