diff options
| author | Shulhan <ms@kilabit.info> | 2019-03-15 22:02:36 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2019-03-17 02:12:43 +0700 |
| commit | 700f1913c1dc6bf1d62c6dcbf12b56da56f2bd1f (patch) | |
| tree | 42a408020cf846064242e66d91e82719115def07 | |
| parent | cc9990d30eb9863e56cdb52197de3610d1853d40 (diff) | |
| download | pakakeh.go-700f1913c1dc6bf1d62c6dcbf12b56da56f2bd1f.tar.xz | |
websocket: unexport Frame Pack()
The Frame Pack method is only used internally, implementor should use
NewFrameXxx functions.
| -rw-r--r-- | lib/websocket/client_test.go | 4 | ||||
| -rw-r--r-- | lib/websocket/frame.go | 6 | ||||
| -rw-r--r-- | lib/websocket/frame_test.go | 2 | ||||
| -rw-r--r-- | lib/websocket/server.go | 2 |
4 files changed, 7 insertions, 7 deletions
diff --git a/lib/websocket/client_test.go b/lib/websocket/client_test.go index ee73c8fc..c6f9f7d9 100644 --- a/lib/websocket/client_test.go +++ b/lib/websocket/client_test.go @@ -419,7 +419,7 @@ func TestClientFragmentation(t *testing.T) { wg.Add(1) for x := 0; x < len(c.frames); x++ { - req := c.frames[x].Pack() + req := c.frames[x].pack() err := testClient.send(req) if err != nil { @@ -500,7 +500,7 @@ func TestClientFragmentation2(t *testing.T) { wg.Add(2) for x := 0; x < len(frames); x++ { - req := frames[x].Pack() + req := frames[x].pack() err := testClient.send(req) if err != nil { diff --git a/lib/websocket/frame.go b/lib/websocket/frame.go index c0e0d6ce..574966a9 100644 --- a/lib/websocket/frame.go +++ b/lib/websocket/frame.go @@ -181,7 +181,7 @@ func NewFrame(opcode Opcode, isMasked bool, payload []byte) []byte { if isMasked { f.masked = frameIsMasked } - return f.Pack() + return f.pack() } // @@ -244,7 +244,7 @@ func (f *Frame) Opcode() Opcode { } // -// Pack WebSocket Frame into packet that can be written into socket. +// pack WebSocket Frame into packet that can be written into socket. // // Frame payload len will be set based on length of payload. // @@ -253,7 +253,7 @@ func (f *Frame) Opcode() Opcode { // A server MUST NOT mask any frames that it sends to the client. // (RFC 6455 5.1-P27). // -func (f *Frame) Pack() (out []byte) { +func (f *Frame) pack() (out []byte) { headerSize := uint64(2) payloadSize := uint64(len(f.payload)) diff --git a/lib/websocket/frame_test.go b/lib/websocket/frame_test.go index e70f8813..1dda4dcb 100644 --- a/lib/websocket/frame_test.go +++ b/lib/websocket/frame_test.go @@ -335,7 +335,7 @@ func TestFramePack(t *testing.T) { for _, c := range cases { t.Log(c.desc) - got := c.f.Pack() + got := c.f.pack() test.Assert(t, "", c.exp, got, true) } diff --git a/lib/websocket/server.go b/lib/websocket/server.go index b3609e3e..2bed8ae9 100644 --- a/lib/websocket/server.go +++ b/lib/websocket/server.go @@ -617,7 +617,7 @@ func (serv *Server) handlePing(conn int, req *Frame) { req.opcode = OpcodePong req.masked = 0 - res := req.Pack() + res := req.pack() err := Send(conn, res) if err != nil { |
