good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
websocket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
github
nhooyr
websocket
Commits
71d69deb
Unverified
Commit
71d69deb
authored
Sep 27, 2019
by
Oleg Kovalov
Committed by
Anmol Sethi
Sep 27, 2019
Browse files
Options
Downloads
Patches
Plain Diff
Improve godoc for status codes
Closes #151
parent
b371dcc0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
frame.go
+26
-21
26 additions, 21 deletions
frame.go
frame_stringer.go
+7
-17
7 additions, 17 deletions
frame_stringer.go
with
33 additions
and
38 deletions
frame.go
+
26
−
21
View file @
71d69deb
...
...
@@ -203,32 +203,37 @@ type StatusCode int
// These codes were retrieved from:
// https://www.iana.org/assignments/websocket/websocket.xhtml#close-code-number
//
// In addition to the defined constants, 4000-4999 may be used by applications.
const
(
StatusNormalClosure
StatusCode
=
1000
+
iota
StatusGoingAway
StatusProtocolError
StatusUnsupportedData
StatusNormalClosure
StatusCode
=
1000
StatusGoingAway
StatusCode
=
1001
StatusProtocolError
StatusCode
=
1002
StatusUnsupportedData
StatusCode
=
1003
_
// 1004 is reserved.
// 1004 is reserved and so not exported.
statusReserved
StatusCode
=
1004
StatusNoStatusRcvd
// StatusNoStatusRcvd cannot be sent as reserved for when
// a close message is received without an explicit status.
StatusNoStatusRcvd
StatusCode
=
1005
//
This
Status
Cod
e is only exported for use with Wasm.
// Status
AbnormalClosur
e is only exported for use with Wasm.
// In non Wasm Go, the returned error will indicate whether the connection was closed or not or what happened.
StatusAbnormalClosure
StatusInvalidFramePayloadData
StatusPolicyViolation
StatusMessageTooBig
StatusMandatoryExtension
StatusInternalError
StatusServiceRestart
StatusTryAgainLater
StatusBadGateway
//
This
Status
Cod
e is only exported for use with Wasm.
StatusAbnormalClosure
StatusCode
=
1006
StatusInvalidFramePayloadData
StatusCode
=
1007
StatusPolicyViolation
StatusCode
=
1008
StatusMessageTooBig
StatusCode
=
1009
StatusMandatoryExtension
StatusCode
=
1010
StatusInternalError
StatusCode
=
1011
StatusServiceRestart
StatusCode
=
1012
StatusTryAgainLater
StatusCode
=
1013
StatusBadGateway
StatusCode
=
1014
// Status
TLSHandshak
e is only exported for use with Wasm.
// In non Wasm Go, the returned error will indicate whether there was a TLS handshake failure.
StatusTLSHandshake
StatusTLSHandshake
StatusCode
=
1015
)
// CloseError represents a WebSocket close frame.
...
...
@@ -272,7 +277,7 @@ func parseClosePayload(p []byte) (CloseError, error) {
// and https://tools.ietf.org/html/rfc6455#section-7.4.1
func
validWireCloseCode
(
code
StatusCode
)
bool
{
switch
code
{
case
1004
,
StatusNoStatusRcvd
,
StatusAbnormalClosure
,
StatusTLSHandshake
:
case
statusReserved
,
StatusNoStatusRcvd
,
StatusAbnormalClosure
,
StatusTLSHandshake
:
return
false
}
...
...
This diff is collapsed.
Click to expand it.
frame_stringer.go
+
7
−
17
View file @
71d69deb
...
...
@@ -64,6 +64,7 @@ func _() {
_
=
x
[
StatusGoingAway
-
1001
]
_
=
x
[
StatusProtocolError
-
1002
]
_
=
x
[
StatusUnsupportedData
-
1003
]
_
=
x
[
statusReserved
-
1004
]
_
=
x
[
StatusNoStatusRcvd
-
1005
]
_
=
x
[
StatusAbnormalClosure
-
1006
]
_
=
x
[
StatusInvalidFramePayloadData
-
1007
]
...
...
@@ -77,25 +78,14 @@ func _() {
_
=
x
[
StatusTLSHandshake
-
1015
]
}
const
(
_StatusCode_name_0
=
"StatusNormalClosureStatusGoingAwayStatusProtocolErrorStatusUnsupportedData"
_StatusCode_name_1
=
"StatusNoStatusRcvdStatusAbnormalClosureStatusInvalidFramePayloadDataStatusPolicyViolationStatusMessageTooBigStatusMandatoryExtensionStatusInternalErrorStatusServiceRestartStatusTryAgainLaterStatusBadGatewayStatusTLSHandshake"
)
const
_StatusCode_name
=
"StatusNormalClosureStatusGoingAwayStatusProtocolErrorStatusUnsupportedDatastatusReservedStatusNoStatusRcvdStatusAbnormalClosureStatusInvalidFramePayloadDataStatusPolicyViolationStatusMessageTooBigStatusMandatoryExtensionStatusInternalErrorStatusServiceRestartStatusTryAgainLaterStatusBadGatewayStatusTLSHandshake"
var
(
_StatusCode_index_0
=
[
...
]
uint8
{
0
,
19
,
34
,
53
,
74
}
_StatusCode_index_1
=
[
...
]
uint8
{
0
,
18
,
39
,
68
,
89
,
108
,
132
,
151
,
171
,
190
,
206
,
224
}
)
var
_StatusCode_index
=
[
...
]
uint16
{
0
,
19
,
34
,
53
,
74
,
88
,
106
,
127
,
156
,
177
,
196
,
220
,
239
,
259
,
278
,
294
,
312
}
func
(
i
StatusCode
)
String
()
string
{
switch
{
case
1000
<=
i
&&
i
<=
1003
:
i
-=
1000
return
_StatusCode_name_0
[
_StatusCode_index_0
[
i
]
:
_StatusCode_index_0
[
i
+
1
]]
case
1005
<=
i
&&
i
<=
1015
:
i
-=
1005
return
_StatusCode_name_1
[
_StatusCode_index_1
[
i
]
:
_StatusCode_index_1
[
i
+
1
]]
default
:
return
"StatusCode("
+
strconv
.
FormatInt
(
int64
(
i
),
10
)
+
")"
if
i
<
0
||
i
>=
StatusCode
(
len
(
_StatusCode_index
)
-
1
)
{
return
"StatusCode("
+
strconv
.
FormatInt
(
int64
(
i
+
1000
),
10
)
+
")"
}
return
_StatusCode_name
[
_StatusCode_index
[
i
]
:
_StatusCode_index
[
i
+
1
]]
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment