conn_read.go

 1// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
 2// Use of this source code is governed by a BSD-style
 3// license that can be found in the LICENSE file.
 4
 5// +build go1.5
 6
 7package websocket
 8
 9import "io"
10
11func (c *Conn) read(n int) ([]byte, error) {
12	p, err := c.br.Peek(n)
13	if err == io.EOF {
14		err = errUnexpectedEOF
15	}
16	c.br.Discard(len(p))
17	return p, err
18}