cloudflare/cloudflared

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2019.11.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

h2mux/error.go

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