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
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
websocket
Commits
12d7f1ac
Unverified
Commit
12d7f1ac
authored
5 years ago
by
Anmol Sethi
Browse files
Options
Downloads
Patches
Plain Diff
Translate the remaining useful Autobahn python tests
parent
a681f25e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ci/test.sh
+1
-2
1 addition, 2 deletions
ci/test.sh
export_test.go
+30
-4
30 additions, 4 deletions
export_test.go
websocket_bench_test.go
+2
-3
2 additions, 3 deletions
websocket_bench_test.go
websocket_test.go
+715
-14
715 additions, 14 deletions
websocket_test.go
with
748 additions
and
23 deletions
ci/test.sh
+
1
−
2
View file @
12d7f1ac
...
...
@@ -12,14 +12,13 @@ argv=(
--
"-vet=off"
)
# Interactive usage does not want to turn off vet or use gotestsum
by default
.
# Interactive usage does not want to turn off vet or use gotestsum.
if
[[
$#
-gt
0
]]
;
then
argv
=(
go
test
"
$@
"
)
fi
# We always want coverage and race detection.
argv+
=(
-race
"-coverprofile=ci/out/coverage.prof"
"-coverpkg=./..."
)
...
...
This diff is collapsed.
Click to expand it.
export_test.go
+
30
−
4
View file @
12d7f1ac
...
...
@@ -15,6 +15,7 @@ type (
const
(
OpClose
=
OpCode
(
opClose
)
OpBinary
=
OpCode
(
opBinary
)
OpText
=
OpCode
(
opText
)
OpPing
=
OpCode
(
opPing
)
OpPong
=
OpCode
(
opPong
)
OpContinuation
=
OpCode
(
opContinuation
)
...
...
@@ -40,17 +41,38 @@ func (c *Conn) WriteFrame(ctx context.Context, fin bool, opc OpCode, p []byte) (
return
c
.
writeFrame
(
ctx
,
fin
,
opcode
(
opc
),
p
)
}
func
(
c
*
Conn
)
WriteHeader
(
ctx
context
.
Context
,
fin
bool
,
opc
OpCode
,
lenp
int64
)
error
{
// header represents a WebSocket frame header.
// See https://tools.ietf.org/html/rfc6455#section-5.2
type
Header
struct
{
Fin
bool
Rsv1
bool
Rsv2
bool
Rsv3
bool
OpCode
OpCode
PayloadLength
int64
}
func
(
c
*
Conn
)
WriteHeader
(
ctx
context
.
Context
,
h
Header
)
error
{
headerBytes
:=
writeHeader
(
c
.
writeHeaderBuf
,
header
{
fin
:
fin
,
opcode
:
opcode
(
opc
),
payloadLength
:
lenp
,
fin
:
h
.
Fin
,
rsv1
:
h
.
Rsv1
,
rsv2
:
h
.
Rsv2
,
rsv3
:
h
.
Rsv3
,
opcode
:
opcode
(
h
.
OpCode
),
payloadLength
:
h
.
PayloadLength
,
masked
:
c
.
client
,
})
_
,
err
:=
c
.
bw
.
Write
(
headerBytes
)
if
err
!=
nil
{
return
xerrors
.
Errorf
(
"failed to write header: %w"
,
err
)
}
if
h
.
Fin
{
err
=
c
.
Flush
()
if
err
!=
nil
{
return
err
}
}
return
nil
}
...
...
@@ -96,3 +118,7 @@ func (c *Conn) WriteClose(ctx context.Context, code StatusCode, reason string) (
}
return
b
,
nil
}
func
ParseClosePayload
(
p
[]
byte
)
(
CloseError
,
error
)
{
return
parseClosePayload
(
p
)
}
This diff is collapsed.
Click to expand it.
websocket_bench_test.go
+
2
−
3
View file @
12d7f1ac
...
...
@@ -5,13 +5,13 @@ import (
"io"
"io/ioutil"
"net/http"
"nhooyr.io/websocket"
"strconv"
"strings"
"testing"
"time"
)
"nhooyr.io/websocket"
)
func
BenchmarkConn
(
b
*
testing
.
B
)
{
sizes
:=
[]
int
{
...
...
@@ -116,7 +116,6 @@ func benchConn(b *testing.B, echo, stream bool, size int) {
c
.
Close
(
websocket
.
StatusNormalClosure
,
""
)
}
func
discardLoop
(
ctx
context
.
Context
,
c
*
websocket
.
Conn
)
{
defer
c
.
Close
(
websocket
.
StatusInternalError
,
""
)
...
...
This diff is collapsed.
Click to expand it.
websocket_test.go
+
715
−
14
View file @
12d7f1ac
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