cloudflare/cloudflared

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2019.8.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

h2mux/error.go

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