cloudflare/cloudflared

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
a2b41ea3e649caeec4835327ad9ff281ecc5990c

Branches

Tags

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

Clone

HTTPS

Download ZIP

h2mux/error.go

66lines · 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 ErrNotRPCStream = MuxerProtocolError{"2004 not RPC stream", http2.ErrCodeProtocol}
23
24 ErrStreamHeadersSent = MuxerApplicationError{"3000 headers already sent"}
25 ErrStreamRequestConnectionClosed = MuxerApplicationError{"3001 connection closed while opening stream"}
26 ErrConnectionDropped = MuxerApplicationError{"3002 connection dropped"}
27 ErrStreamRequestTimeout = MuxerApplicationError{"3003 open stream timeout"}
28 ErrResponseHeadersTimeout = MuxerApplicationError{"3004 timeout waiting for initial response headers"}
29 ErrResponseHeadersConnectionClosed = MuxerApplicationError{"3005 connection closed while waiting for initial response headers"}
30
31 ErrClosedStream = MuxerStreamError{"4000 stream closed", http2.ErrCodeStreamClosed}
32)
33
34type MuxerHandshakeError struct {
35 cause string
36}
37
38func (e MuxerHandshakeError) Error() string {
39 return fmt.Sprintf("Handshake error: %s", e.cause)
40}
41
42type MuxerProtocolError struct {
43 cause string
44 h2code http2.ErrCode
45}
46
47func (e MuxerProtocolError) Error() string {
48 return fmt.Sprintf("Protocol error: %s", e.cause)
49}
50
51type MuxerApplicationError struct {
52 cause string
53}
54
55func (e MuxerApplicationError) Error() string {
56 return fmt.Sprintf("Application error: %s", e.cause)
57}
58
59type MuxerStreamError struct {
60 cause string
61 h2code http2.ErrCode
62}
63
64func (e MuxerStreamError) Error() string {
65 return fmt.Sprintf("Stream error: %s", e.cause)
66}
67