slidge-whatsapp 0.3.7__cp312-cp312-manylinux_2_41_aarch64.whl → 0.3.8__cp312-cp312-manylinux_2_41_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- slidge_whatsapp/config.py +7 -2
- slidge_whatsapp/contact.py +3 -2
- slidge_whatsapp/event.go +14 -9
- slidge_whatsapp/gateway.go +7 -1
- slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.h +182 -178
- slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.so +0 -0
- slidge_whatsapp/generated/build.py +146 -142
- slidge_whatsapp/generated/whatsapp.c +1456 -1376
- slidge_whatsapp/generated/whatsapp.go +1069 -1045
- slidge_whatsapp/generated/whatsapp.py +1324 -1298
- slidge_whatsapp/generated/whatsapp_go.h +182 -178
- slidge_whatsapp/go.mod +6 -6
- slidge_whatsapp/go.sum +12 -12
- slidge_whatsapp/group.py +25 -0
- slidge_whatsapp/session.go +69 -67
- slidge_whatsapp/session.py +11 -1
- slidge_whatsapp/vendor/github.com/coder/websocket/LICENSE.txt +13 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/Makefile +18 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/README.md +162 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/accept.go +378 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/close.go +335 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/compress.go +234 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/conn.go +306 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/dial.go +347 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/doc.go +33 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/errors.go +8 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/frame.go +173 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/hijack.go +33 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/internal/bpool/bpool.go +25 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/internal/errd/wrap.go +14 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/internal/util/util.go +15 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/internal/wsjs/wsjs_js.go +169 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask.go +128 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask_amd64.s +127 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask_arm64.s +72 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask_asm.go +26 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask_go.go +7 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/netconn.go +233 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/netconn_js.go +11 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/netconn_notjs.go +19 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/read.go +540 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/stringer.go +91 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/write.go +384 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/ws_js.go +598 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/func.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_amd64.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_arm64.go +3 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_loong64.go +1 -1
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/directive.go +3 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/selection.go +3 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/value.go +4 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/encode.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +18 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/broadcast.go +3 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +6 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/client.go +90 -80
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/connectionevents.go +14 -11
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download.go +4 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +47 -48
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/handshake.go +3 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +79 -75
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/keepalive.go +8 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/mediaconn.go +1 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/mediaretry.go +2 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +42 -40
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/newsletter.go +35 -32
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +2 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair-code.go +2 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair.go +19 -19
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/prekeys.go +9 -8
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/presence.go +9 -9
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/privacysettings.go +4 -5
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAICommon/WAAICommon.pb.go +1145 -335
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAICommon/WAAICommon.proto +78 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAdv/WAAdv.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloApplication/WAArmadilloApplication.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCert/WACert.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waChatLockSettings/WAProtobufsChatLockSettings.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCommon/WACommon.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.pb.go +22 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.proto +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waConsumerApplication/WAConsumerApplication.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.pb.go +104 -30
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.proto +7 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +1037 -963
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +15 -8
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMediaTransport/WAMediaTransport.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMmsRetry/WAMmsRetry.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgApplication/WAMsgApplication.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/WAMsgTransport.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMultiDevice/WAMultiDevice.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waServerSync/WAServerSync.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +40 -35
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +921 -653
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +44 -15
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waUserPassword/WAProtobufsUserPassword.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waVnameCert/WAWebProtobufsVnameCert.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.go +9 -5
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.proto +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +193 -115
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +9 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/push.go +2 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +12 -12
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/request.go +25 -19
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +2 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +43 -27
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/sendfb.go +4 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/constants.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/framesocket.go +43 -56
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/noisehandshake.go +9 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/noisesocket.go +36 -22
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +24 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +12 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/events/appstate.go +2 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/upload.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +79 -40
- slidge_whatsapp/vendor/golang.org/x/sys/unix/mkerrors.sh +2 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_linux.go +6 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux.go +359 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_linux.go +10 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux.go +31 -0
- slidge_whatsapp/vendor/golang.org/x/sys/windows/syscall_windows.go +15 -0
- slidge_whatsapp/vendor/golang.org/x/sys/windows/types_windows.go +76 -0
- slidge_whatsapp/vendor/golang.org/x/sys/windows/zsyscall_windows.go +37 -0
- slidge_whatsapp/vendor/modules.txt +12 -8
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/METADATA +1 -1
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/RECORD +145 -136
- slidge_whatsapp/vendor/github.com/gorilla/websocket/.gitignore +0 -25
- slidge_whatsapp/vendor/github.com/gorilla/websocket/AUTHORS +0 -9
- slidge_whatsapp/vendor/github.com/gorilla/websocket/LICENSE +0 -22
- slidge_whatsapp/vendor/github.com/gorilla/websocket/README.md +0 -33
- slidge_whatsapp/vendor/github.com/gorilla/websocket/client.go +0 -434
- slidge_whatsapp/vendor/github.com/gorilla/websocket/compression.go +0 -148
- slidge_whatsapp/vendor/github.com/gorilla/websocket/conn.go +0 -1238
- slidge_whatsapp/vendor/github.com/gorilla/websocket/doc.go +0 -227
- slidge_whatsapp/vendor/github.com/gorilla/websocket/join.go +0 -42
- slidge_whatsapp/vendor/github.com/gorilla/websocket/json.go +0 -60
- slidge_whatsapp/vendor/github.com/gorilla/websocket/mask.go +0 -55
- slidge_whatsapp/vendor/github.com/gorilla/websocket/mask_safe.go +0 -16
- slidge_whatsapp/vendor/github.com/gorilla/websocket/prepared.go +0 -102
- slidge_whatsapp/vendor/github.com/gorilla/websocket/proxy.go +0 -77
- slidge_whatsapp/vendor/github.com/gorilla/websocket/server.go +0 -365
- slidge_whatsapp/vendor/github.com/gorilla/websocket/tls_handshake.go +0 -21
- slidge_whatsapp/vendor/github.com/gorilla/websocket/tls_handshake_116.go +0 -21
- slidge_whatsapp/vendor/github.com/gorilla/websocket/util.go +0 -298
- slidge_whatsapp/vendor/github.com/gorilla/websocket/x_net_proxy.go +0 -473
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/WHEEL +0 -0
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/entry_points.txt +0 -0
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
//go:build !js
|
|
2
|
+
|
|
3
|
+
package websocket
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"bufio"
|
|
7
|
+
"context"
|
|
8
|
+
"errors"
|
|
9
|
+
"fmt"
|
|
10
|
+
"io"
|
|
11
|
+
"net"
|
|
12
|
+
"strings"
|
|
13
|
+
"sync/atomic"
|
|
14
|
+
"time"
|
|
15
|
+
|
|
16
|
+
"github.com/coder/websocket/internal/errd"
|
|
17
|
+
"github.com/coder/websocket/internal/util"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
// Reader reads from the connection until there is a WebSocket
|
|
21
|
+
// data message to be read. It will handle ping, pong and close frames as appropriate.
|
|
22
|
+
//
|
|
23
|
+
// It returns the type of the message and an io.Reader to read it.
|
|
24
|
+
// The passed context will also bound the reader.
|
|
25
|
+
// Ensure you read to EOF otherwise the connection will hang.
|
|
26
|
+
//
|
|
27
|
+
// Call CloseRead if you do not expect any data messages from the peer.
|
|
28
|
+
//
|
|
29
|
+
// Only one Reader may be open at a time.
|
|
30
|
+
//
|
|
31
|
+
// If you need a separate timeout on the Reader call and the Read itself,
|
|
32
|
+
// use time.AfterFunc to cancel the context passed in.
|
|
33
|
+
// See https://github.com/nhooyr/websocket/issues/87#issue-451703332
|
|
34
|
+
// Most users should not need this.
|
|
35
|
+
func (c *Conn) Reader(ctx context.Context) (MessageType, io.Reader, error) {
|
|
36
|
+
return c.reader(ctx)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Read is a convenience method around Reader to read a single message
|
|
40
|
+
// from the connection.
|
|
41
|
+
func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) {
|
|
42
|
+
typ, r, err := c.Reader(ctx)
|
|
43
|
+
if err != nil {
|
|
44
|
+
return 0, nil, err
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
b, err := io.ReadAll(r)
|
|
48
|
+
return typ, b, err
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// CloseRead starts a goroutine to read from the connection until it is closed
|
|
52
|
+
// or a data message is received.
|
|
53
|
+
//
|
|
54
|
+
// Once CloseRead is called you cannot read any messages from the connection.
|
|
55
|
+
// The returned context will be cancelled when the connection is closed.
|
|
56
|
+
//
|
|
57
|
+
// If a data message is received, the connection will be closed with StatusPolicyViolation.
|
|
58
|
+
//
|
|
59
|
+
// Call CloseRead when you do not expect to read any more messages.
|
|
60
|
+
// Since it actively reads from the connection, it will ensure that ping, pong and close
|
|
61
|
+
// frames are responded to. This means c.Ping and c.Close will still work as expected.
|
|
62
|
+
//
|
|
63
|
+
// This function is idempotent.
|
|
64
|
+
func (c *Conn) CloseRead(ctx context.Context) context.Context {
|
|
65
|
+
c.closeReadMu.Lock()
|
|
66
|
+
ctx2 := c.closeReadCtx
|
|
67
|
+
if ctx2 != nil {
|
|
68
|
+
c.closeReadMu.Unlock()
|
|
69
|
+
return ctx2
|
|
70
|
+
}
|
|
71
|
+
ctx, cancel := context.WithCancel(ctx)
|
|
72
|
+
c.closeReadCtx = ctx
|
|
73
|
+
c.closeReadDone = make(chan struct{})
|
|
74
|
+
c.closeReadMu.Unlock()
|
|
75
|
+
|
|
76
|
+
go func() {
|
|
77
|
+
defer close(c.closeReadDone)
|
|
78
|
+
defer cancel()
|
|
79
|
+
defer c.close()
|
|
80
|
+
_, _, err := c.Reader(ctx)
|
|
81
|
+
if err == nil {
|
|
82
|
+
c.Close(StatusPolicyViolation, "unexpected data message")
|
|
83
|
+
}
|
|
84
|
+
}()
|
|
85
|
+
return ctx
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// SetReadLimit sets the max number of bytes to read for a single message.
|
|
89
|
+
// It applies to the Reader and Read methods.
|
|
90
|
+
//
|
|
91
|
+
// By default, the connection has a message read limit of 32768 bytes.
|
|
92
|
+
//
|
|
93
|
+
// When the limit is hit, reads return an error wrapping ErrMessageTooBig and
|
|
94
|
+
// the connection is closed with StatusMessageTooBig.
|
|
95
|
+
//
|
|
96
|
+
// Set to -1 to disable.
|
|
97
|
+
func (c *Conn) SetReadLimit(n int64) {
|
|
98
|
+
if n >= 0 {
|
|
99
|
+
// We read one more byte than the limit in case
|
|
100
|
+
// there is a fin frame that needs to be read.
|
|
101
|
+
n++
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
c.msgReader.limitReader.limit.Store(n)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const defaultReadLimit = 32768
|
|
108
|
+
|
|
109
|
+
func newMsgReader(c *Conn) *msgReader {
|
|
110
|
+
mr := &msgReader{
|
|
111
|
+
c: c,
|
|
112
|
+
fin: true,
|
|
113
|
+
}
|
|
114
|
+
mr.readFunc = mr.read
|
|
115
|
+
|
|
116
|
+
mr.limitReader = newLimitReader(c, mr.readFunc, defaultReadLimit+1)
|
|
117
|
+
return mr
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
func (mr *msgReader) resetFlate() {
|
|
121
|
+
if mr.flateContextTakeover() {
|
|
122
|
+
if mr.dict == nil {
|
|
123
|
+
mr.dict = &slidingWindow{}
|
|
124
|
+
}
|
|
125
|
+
mr.dict.init(32768)
|
|
126
|
+
}
|
|
127
|
+
if mr.flateBufio == nil {
|
|
128
|
+
mr.flateBufio = getBufioReader(mr.readFunc)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if mr.flateContextTakeover() {
|
|
132
|
+
mr.flateReader = getFlateReader(mr.flateBufio, mr.dict.buf)
|
|
133
|
+
} else {
|
|
134
|
+
mr.flateReader = getFlateReader(mr.flateBufio, nil)
|
|
135
|
+
}
|
|
136
|
+
mr.limitReader.r = mr.flateReader
|
|
137
|
+
mr.flateTail.Reset(deflateMessageTail)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
func (mr *msgReader) putFlateReader() {
|
|
141
|
+
if mr.flateReader != nil {
|
|
142
|
+
putFlateReader(mr.flateReader)
|
|
143
|
+
mr.flateReader = nil
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
func (mr *msgReader) close() {
|
|
148
|
+
mr.c.readMu.forceLock()
|
|
149
|
+
mr.putFlateReader()
|
|
150
|
+
if mr.dict != nil {
|
|
151
|
+
mr.dict.close()
|
|
152
|
+
mr.dict = nil
|
|
153
|
+
}
|
|
154
|
+
if mr.flateBufio != nil {
|
|
155
|
+
putBufioReader(mr.flateBufio)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if mr.c.client {
|
|
159
|
+
putBufioReader(mr.c.br)
|
|
160
|
+
mr.c.br = nil
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
func (mr *msgReader) flateContextTakeover() bool {
|
|
165
|
+
if mr.c.client {
|
|
166
|
+
return !mr.c.copts.serverNoContextTakeover
|
|
167
|
+
}
|
|
168
|
+
return !mr.c.copts.clientNoContextTakeover
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
func (c *Conn) readRSV1Illegal(h header) bool {
|
|
172
|
+
// If compression is disabled, rsv1 is illegal.
|
|
173
|
+
if !c.flate() {
|
|
174
|
+
return true
|
|
175
|
+
}
|
|
176
|
+
// rsv1 is only allowed on data frames beginning messages.
|
|
177
|
+
if h.opcode != opText && h.opcode != opBinary {
|
|
178
|
+
return true
|
|
179
|
+
}
|
|
180
|
+
return false
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
func (c *Conn) readLoop(ctx context.Context) (header, error) {
|
|
184
|
+
for {
|
|
185
|
+
h, err := c.readFrameHeader(ctx)
|
|
186
|
+
if err != nil {
|
|
187
|
+
return header{}, err
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if h.rsv1 && c.readRSV1Illegal(h) || h.rsv2 || h.rsv3 {
|
|
191
|
+
err := fmt.Errorf("received header with unexpected rsv bits set: %v:%v:%v", h.rsv1, h.rsv2, h.rsv3)
|
|
192
|
+
c.writeError(StatusProtocolError, err)
|
|
193
|
+
return header{}, err
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if !c.client && !h.masked {
|
|
197
|
+
return header{}, errors.New("received unmasked frame from client")
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
switch h.opcode {
|
|
201
|
+
case opClose, opPing, opPong:
|
|
202
|
+
err = c.handleControl(ctx, h)
|
|
203
|
+
if err != nil {
|
|
204
|
+
// Pass through CloseErrors when receiving a close frame.
|
|
205
|
+
if h.opcode == opClose && CloseStatus(err) != -1 {
|
|
206
|
+
return header{}, err
|
|
207
|
+
}
|
|
208
|
+
return header{}, fmt.Errorf("failed to handle control frame %v: %w", h.opcode, err)
|
|
209
|
+
}
|
|
210
|
+
case opContinuation, opText, opBinary:
|
|
211
|
+
return h, nil
|
|
212
|
+
default:
|
|
213
|
+
err := fmt.Errorf("received unknown opcode %v", h.opcode)
|
|
214
|
+
c.writeError(StatusProtocolError, err)
|
|
215
|
+
return header{}, err
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// prepareRead sets the readTimeout context and returns a done function
|
|
221
|
+
// to be called after the read is done. It also returns an error if the
|
|
222
|
+
// connection is closed. The reference to the error is used to assign
|
|
223
|
+
// an error depending on if the connection closed or the context timed
|
|
224
|
+
// out during use. Typically, the referenced error is a named return
|
|
225
|
+
// variable of the function calling this method.
|
|
226
|
+
func (c *Conn) prepareRead(ctx context.Context, err *error) (func(), error) {
|
|
227
|
+
select {
|
|
228
|
+
case <-c.closed:
|
|
229
|
+
return nil, net.ErrClosed
|
|
230
|
+
default:
|
|
231
|
+
}
|
|
232
|
+
c.setupReadTimeout(ctx)
|
|
233
|
+
|
|
234
|
+
done := func() {
|
|
235
|
+
c.clearReadTimeout()
|
|
236
|
+
select {
|
|
237
|
+
case <-c.closed:
|
|
238
|
+
if *err != nil {
|
|
239
|
+
*err = net.ErrClosed
|
|
240
|
+
}
|
|
241
|
+
default:
|
|
242
|
+
}
|
|
243
|
+
if *err != nil && ctx.Err() != nil {
|
|
244
|
+
*err = ctx.Err()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
c.closeStateMu.Lock()
|
|
249
|
+
closeReceivedErr := c.closeReceivedErr
|
|
250
|
+
c.closeStateMu.Unlock()
|
|
251
|
+
if closeReceivedErr != nil {
|
|
252
|
+
defer done()
|
|
253
|
+
return nil, closeReceivedErr
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return done, nil
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
func (c *Conn) readFrameHeader(ctx context.Context) (_ header, err error) {
|
|
260
|
+
readDone, err := c.prepareRead(ctx, &err)
|
|
261
|
+
if err != nil {
|
|
262
|
+
return header{}, err
|
|
263
|
+
}
|
|
264
|
+
defer readDone()
|
|
265
|
+
|
|
266
|
+
h, err := readFrameHeader(c.br, c.readHeaderBuf[:])
|
|
267
|
+
if err != nil {
|
|
268
|
+
return header{}, err
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return h, nil
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
func (c *Conn) readFramePayload(ctx context.Context, p []byte) (_ int, err error) {
|
|
275
|
+
readDone, err := c.prepareRead(ctx, &err)
|
|
276
|
+
if err != nil {
|
|
277
|
+
return 0, err
|
|
278
|
+
}
|
|
279
|
+
defer readDone()
|
|
280
|
+
|
|
281
|
+
n, err := io.ReadFull(c.br, p)
|
|
282
|
+
if err != nil {
|
|
283
|
+
return n, fmt.Errorf("failed to read frame payload: %w", err)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return n, nil
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
func (c *Conn) handleControl(ctx context.Context, h header) (err error) {
|
|
290
|
+
if h.payloadLength < 0 || h.payloadLength > maxControlPayload {
|
|
291
|
+
err := fmt.Errorf("received control frame payload with invalid length: %d", h.payloadLength)
|
|
292
|
+
c.writeError(StatusProtocolError, err)
|
|
293
|
+
return err
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if !h.fin {
|
|
297
|
+
err := errors.New("received fragmented control frame")
|
|
298
|
+
c.writeError(StatusProtocolError, err)
|
|
299
|
+
return err
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
ctx, cancel := context.WithTimeout(ctx, time.Second*5)
|
|
303
|
+
defer cancel()
|
|
304
|
+
|
|
305
|
+
b := c.readControlBuf[:h.payloadLength]
|
|
306
|
+
_, err = c.readFramePayload(ctx, b)
|
|
307
|
+
if err != nil {
|
|
308
|
+
return err
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if h.masked {
|
|
312
|
+
mask(b, h.maskKey)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
switch h.opcode {
|
|
316
|
+
case opPing:
|
|
317
|
+
if c.onPingReceived != nil {
|
|
318
|
+
if !c.onPingReceived(ctx, b) {
|
|
319
|
+
return nil
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return c.writeControl(ctx, opPong, b)
|
|
323
|
+
case opPong:
|
|
324
|
+
if c.onPongReceived != nil {
|
|
325
|
+
c.onPongReceived(ctx, b)
|
|
326
|
+
}
|
|
327
|
+
c.activePingsMu.Lock()
|
|
328
|
+
pong, ok := c.activePings[string(b)]
|
|
329
|
+
c.activePingsMu.Unlock()
|
|
330
|
+
if ok {
|
|
331
|
+
select {
|
|
332
|
+
case pong <- struct{}{}:
|
|
333
|
+
default:
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return nil
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// opClose
|
|
340
|
+
|
|
341
|
+
ce, err := parseClosePayload(b)
|
|
342
|
+
if err != nil {
|
|
343
|
+
err = fmt.Errorf("received invalid close payload: %w", err)
|
|
344
|
+
c.writeError(StatusProtocolError, err)
|
|
345
|
+
return err
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
err = fmt.Errorf("received close frame: %w", ce)
|
|
349
|
+
c.closeStateMu.Lock()
|
|
350
|
+
c.closeReceivedErr = err
|
|
351
|
+
closeSent := c.closeSentErr != nil
|
|
352
|
+
c.closeStateMu.Unlock()
|
|
353
|
+
|
|
354
|
+
// Only unlock readMu if this connection is being closed becaue
|
|
355
|
+
// c.close will try to acquire the readMu lock. We unlock for
|
|
356
|
+
// writeClose as well because it may also call c.close.
|
|
357
|
+
if !closeSent {
|
|
358
|
+
c.readMu.unlock()
|
|
359
|
+
_ = c.writeClose(ce.Code, ce.Reason)
|
|
360
|
+
}
|
|
361
|
+
if !c.casClosing() {
|
|
362
|
+
c.readMu.unlock()
|
|
363
|
+
_ = c.close()
|
|
364
|
+
}
|
|
365
|
+
return err
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
func (c *Conn) reader(ctx context.Context) (_ MessageType, _ io.Reader, err error) {
|
|
369
|
+
defer errd.Wrap(&err, "failed to get reader")
|
|
370
|
+
|
|
371
|
+
err = c.readMu.lock(ctx)
|
|
372
|
+
if err != nil {
|
|
373
|
+
return 0, nil, err
|
|
374
|
+
}
|
|
375
|
+
defer c.readMu.unlock()
|
|
376
|
+
|
|
377
|
+
if !c.msgReader.fin {
|
|
378
|
+
return 0, nil, errors.New("previous message not read to completion")
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
h, err := c.readLoop(ctx)
|
|
382
|
+
if err != nil {
|
|
383
|
+
return 0, nil, err
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if h.opcode == opContinuation {
|
|
387
|
+
err := errors.New("received continuation frame without text or binary frame")
|
|
388
|
+
c.writeError(StatusProtocolError, err)
|
|
389
|
+
return 0, nil, err
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
c.msgReader.reset(ctx, h)
|
|
393
|
+
|
|
394
|
+
return MessageType(h.opcode), c.msgReader, nil
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
type msgReader struct {
|
|
398
|
+
c *Conn
|
|
399
|
+
|
|
400
|
+
ctx context.Context
|
|
401
|
+
flate bool
|
|
402
|
+
flateReader io.Reader
|
|
403
|
+
flateBufio *bufio.Reader
|
|
404
|
+
flateTail strings.Reader
|
|
405
|
+
limitReader *limitReader
|
|
406
|
+
dict *slidingWindow
|
|
407
|
+
|
|
408
|
+
fin bool
|
|
409
|
+
payloadLength int64
|
|
410
|
+
maskKey uint32
|
|
411
|
+
|
|
412
|
+
// util.ReaderFunc(mr.Read) to avoid continuous allocations.
|
|
413
|
+
readFunc util.ReaderFunc
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
func (mr *msgReader) reset(ctx context.Context, h header) {
|
|
417
|
+
mr.ctx = ctx
|
|
418
|
+
mr.flate = h.rsv1
|
|
419
|
+
mr.limitReader.reset(mr.readFunc)
|
|
420
|
+
|
|
421
|
+
if mr.flate {
|
|
422
|
+
mr.resetFlate()
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
mr.setFrame(h)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
func (mr *msgReader) setFrame(h header) {
|
|
429
|
+
mr.fin = h.fin
|
|
430
|
+
mr.payloadLength = h.payloadLength
|
|
431
|
+
mr.maskKey = h.maskKey
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
func (mr *msgReader) Read(p []byte) (n int, err error) {
|
|
435
|
+
err = mr.c.readMu.lock(mr.ctx)
|
|
436
|
+
if err != nil {
|
|
437
|
+
return 0, fmt.Errorf("failed to read: %w", err)
|
|
438
|
+
}
|
|
439
|
+
defer mr.c.readMu.unlock()
|
|
440
|
+
|
|
441
|
+
n, err = mr.limitReader.Read(p)
|
|
442
|
+
if mr.flate && mr.flateContextTakeover() {
|
|
443
|
+
p = p[:n]
|
|
444
|
+
mr.dict.write(p)
|
|
445
|
+
}
|
|
446
|
+
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) && mr.fin && mr.flate {
|
|
447
|
+
mr.putFlateReader()
|
|
448
|
+
return n, io.EOF
|
|
449
|
+
}
|
|
450
|
+
if err != nil {
|
|
451
|
+
return n, fmt.Errorf("failed to read: %w", err)
|
|
452
|
+
}
|
|
453
|
+
return n, nil
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
func (mr *msgReader) read(p []byte) (int, error) {
|
|
457
|
+
for {
|
|
458
|
+
if mr.payloadLength == 0 {
|
|
459
|
+
if mr.fin {
|
|
460
|
+
if mr.flate {
|
|
461
|
+
return mr.flateTail.Read(p)
|
|
462
|
+
}
|
|
463
|
+
return 0, io.EOF
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
h, err := mr.c.readLoop(mr.ctx)
|
|
467
|
+
if err != nil {
|
|
468
|
+
return 0, err
|
|
469
|
+
}
|
|
470
|
+
if h.opcode != opContinuation {
|
|
471
|
+
err := errors.New("received new data message without finishing the previous message")
|
|
472
|
+
mr.c.writeError(StatusProtocolError, err)
|
|
473
|
+
return 0, err
|
|
474
|
+
}
|
|
475
|
+
mr.setFrame(h)
|
|
476
|
+
|
|
477
|
+
continue
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if int64(len(p)) > mr.payloadLength {
|
|
481
|
+
p = p[:mr.payloadLength]
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
n, err := mr.c.readFramePayload(mr.ctx, p)
|
|
485
|
+
if err != nil {
|
|
486
|
+
return n, err
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
mr.payloadLength -= int64(n)
|
|
490
|
+
|
|
491
|
+
if !mr.c.client {
|
|
492
|
+
mr.maskKey = mask(p, mr.maskKey)
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return n, nil
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
type limitReader struct {
|
|
500
|
+
c *Conn
|
|
501
|
+
r io.Reader
|
|
502
|
+
limit atomic.Int64
|
|
503
|
+
n int64
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
func newLimitReader(c *Conn, r io.Reader, limit int64) *limitReader {
|
|
507
|
+
lr := &limitReader{
|
|
508
|
+
c: c,
|
|
509
|
+
}
|
|
510
|
+
lr.limit.Store(limit)
|
|
511
|
+
lr.reset(r)
|
|
512
|
+
return lr
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
func (lr *limitReader) reset(r io.Reader) {
|
|
516
|
+
lr.n = lr.limit.Load()
|
|
517
|
+
lr.r = r
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
func (lr *limitReader) Read(p []byte) (int, error) {
|
|
521
|
+
if lr.n < 0 {
|
|
522
|
+
return lr.r.Read(p)
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if lr.n == 0 {
|
|
526
|
+
reason := fmt.Errorf("read limited at %d bytes", lr.limit.Load())
|
|
527
|
+
lr.c.writeError(StatusMessageTooBig, reason)
|
|
528
|
+
return 0, fmt.Errorf("%w: %v", ErrMessageTooBig, reason)
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if int64(len(p)) > lr.n {
|
|
532
|
+
p = p[:lr.n]
|
|
533
|
+
}
|
|
534
|
+
n, err := lr.r.Read(p)
|
|
535
|
+
lr.n -= int64(n)
|
|
536
|
+
if lr.n < 0 {
|
|
537
|
+
lr.n = 0
|
|
538
|
+
}
|
|
539
|
+
return n, err
|
|
540
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Code generated by "stringer -type=opcode,MessageType,StatusCode -output=stringer.go"; DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
package websocket
|
|
4
|
+
|
|
5
|
+
import "strconv"
|
|
6
|
+
|
|
7
|
+
func _() {
|
|
8
|
+
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
9
|
+
// Re-run the stringer command to generate them again.
|
|
10
|
+
var x [1]struct{}
|
|
11
|
+
_ = x[opContinuation-0]
|
|
12
|
+
_ = x[opText-1]
|
|
13
|
+
_ = x[opBinary-2]
|
|
14
|
+
_ = x[opClose-8]
|
|
15
|
+
_ = x[opPing-9]
|
|
16
|
+
_ = x[opPong-10]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const (
|
|
20
|
+
_opcode_name_0 = "opContinuationopTextopBinary"
|
|
21
|
+
_opcode_name_1 = "opCloseopPingopPong"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
var (
|
|
25
|
+
_opcode_index_0 = [...]uint8{0, 14, 20, 28}
|
|
26
|
+
_opcode_index_1 = [...]uint8{0, 7, 13, 19}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
func (i opcode) String() string {
|
|
30
|
+
switch {
|
|
31
|
+
case 0 <= i && i <= 2:
|
|
32
|
+
return _opcode_name_0[_opcode_index_0[i]:_opcode_index_0[i+1]]
|
|
33
|
+
case 8 <= i && i <= 10:
|
|
34
|
+
i -= 8
|
|
35
|
+
return _opcode_name_1[_opcode_index_1[i]:_opcode_index_1[i+1]]
|
|
36
|
+
default:
|
|
37
|
+
return "opcode(" + strconv.FormatInt(int64(i), 10) + ")"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
func _() {
|
|
41
|
+
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
42
|
+
// Re-run the stringer command to generate them again.
|
|
43
|
+
var x [1]struct{}
|
|
44
|
+
_ = x[MessageText-1]
|
|
45
|
+
_ = x[MessageBinary-2]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const _MessageType_name = "MessageTextMessageBinary"
|
|
49
|
+
|
|
50
|
+
var _MessageType_index = [...]uint8{0, 11, 24}
|
|
51
|
+
|
|
52
|
+
func (i MessageType) String() string {
|
|
53
|
+
i -= 1
|
|
54
|
+
if i < 0 || i >= MessageType(len(_MessageType_index)-1) {
|
|
55
|
+
return "MessageType(" + strconv.FormatInt(int64(i+1), 10) + ")"
|
|
56
|
+
}
|
|
57
|
+
return _MessageType_name[_MessageType_index[i]:_MessageType_index[i+1]]
|
|
58
|
+
}
|
|
59
|
+
func _() {
|
|
60
|
+
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
61
|
+
// Re-run the stringer command to generate them again.
|
|
62
|
+
var x [1]struct{}
|
|
63
|
+
_ = x[StatusNormalClosure-1000]
|
|
64
|
+
_ = x[StatusGoingAway-1001]
|
|
65
|
+
_ = x[StatusProtocolError-1002]
|
|
66
|
+
_ = x[StatusUnsupportedData-1003]
|
|
67
|
+
_ = x[statusReserved-1004]
|
|
68
|
+
_ = x[StatusNoStatusRcvd-1005]
|
|
69
|
+
_ = x[StatusAbnormalClosure-1006]
|
|
70
|
+
_ = x[StatusInvalidFramePayloadData-1007]
|
|
71
|
+
_ = x[StatusPolicyViolation-1008]
|
|
72
|
+
_ = x[StatusMessageTooBig-1009]
|
|
73
|
+
_ = x[StatusMandatoryExtension-1010]
|
|
74
|
+
_ = x[StatusInternalError-1011]
|
|
75
|
+
_ = x[StatusServiceRestart-1012]
|
|
76
|
+
_ = x[StatusTryAgainLater-1013]
|
|
77
|
+
_ = x[StatusBadGateway-1014]
|
|
78
|
+
_ = x[StatusTLSHandshake-1015]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const _StatusCode_name = "StatusNormalClosureStatusGoingAwayStatusProtocolErrorStatusUnsupportedDatastatusReservedStatusNoStatusRcvdStatusAbnormalClosureStatusInvalidFramePayloadDataStatusPolicyViolationStatusMessageTooBigStatusMandatoryExtensionStatusInternalErrorStatusServiceRestartStatusTryAgainLaterStatusBadGatewayStatusTLSHandshake"
|
|
82
|
+
|
|
83
|
+
var _StatusCode_index = [...]uint16{0, 19, 34, 53, 74, 88, 106, 127, 156, 177, 196, 220, 239, 259, 278, 294, 312}
|
|
84
|
+
|
|
85
|
+
func (i StatusCode) String() string {
|
|
86
|
+
i -= 1000
|
|
87
|
+
if i < 0 || i >= StatusCode(len(_StatusCode_index)-1) {
|
|
88
|
+
return "StatusCode(" + strconv.FormatInt(int64(i+1000), 10) + ")"
|
|
89
|
+
}
|
|
90
|
+
return _StatusCode_name[_StatusCode_index[i]:_StatusCode_index[i+1]]
|
|
91
|
+
}
|