cloudflare/cloudflared

Public

mirrored from https://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
809d2f3f28fa90e732f5063e704e7ae371df4201

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

h2mux/error.go

63lines · modecode

1package h2mux
2
3import (
4 "fmt"
5
6 "golang.org/x/net/http2"
7)
8
9var (
10 // HTTP2 error codes: https://http2.github.io/http2-spec/#ErrorCodes
11 ErrHandshakeTimeout = MuxerHandshakeError{"1000 handshake timeout"}
12 ErrBadHandshakeNotSettings = MuxerHandshakeError{"1001 unexpected response"}
13 ErrBadHandshakeUnexpectedAck = MuxerHandshakeError{"1002 unexpected response"}
14 ErrBadHandshakeNoMagic = MuxerHandshakeError{"1003 unexpected response"}
15 ErrBadHandshakeWrongMagic = MuxerHandshakeError{"1004 connected to endpoint of wrong type"}
16 ErrBadHandshakeNotSettingsAck = MuxerHandshakeError{"1005 unexpected response"}
17 ErrBadHandshakeUnexpectedSettings = MuxerHandshakeError{"1006 unexpected response"}
18
19 ErrUnexpectedFrameType = MuxerProtocolError{"2001 unexpected frame type", http2.ErrCodeProtocol}
20 ErrUnknownStream = MuxerProtocolError{"2002 unknown stream", http2.ErrCodeProtocol}
21 ErrInvalidStream = MuxerProtocolError{"2003 invalid stream", http2.ErrCodeProtocol}
22
23 ErrStreamHeadersSent = MuxerApplicationError{"3000 headers already sent"}
24 ErrConnectionClosed = MuxerApplicationError{"3001 connection closed"}
25 ErrConnectionDropped = MuxerApplicationError{"3002 connection dropped"}
26 ErrOpenStreamTimeout = MuxerApplicationError{"3003 open stream timeout"}
27
28 ErrClosedStream = MuxerStreamError{"4000 stream closed", http2.ErrCodeStreamClosed}
29)
30
31type MuxerHandshakeError struct {
32 cause string
33}
34
35func (e MuxerHandshakeError) Error() string {
36 return fmt.Sprintf("Handshake error: %s", e.cause)
37}
38
39type MuxerProtocolError struct {
40 cause string
41 h2code http2.ErrCode
42}
43
44func (e MuxerProtocolError) Error() string {
45 return fmt.Sprintf("Protocol error: %s", e.cause)
46}
47
48type MuxerApplicationError struct {
49 cause string
50}
51
52func (e MuxerApplicationError) Error() string {
53 return fmt.Sprintf("Application error: %s", e.cause)
54}
55
56type MuxerStreamError struct {
57 cause string
58 h2code http2.ErrCode
59}
60
61func (e MuxerStreamError) Error() string {
62 return fmt.Sprintf("Stream error: %s", e.cause)
63}
64