good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 12d7f1ac authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Translate the remaining useful Autobahn python tests

parent a681f25e
No related branches found
No related tags found
No related merge requests found
......@@ -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=./..."
)
......
......@@ -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)
}
......@@ -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.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment