khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 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 | |
| 7 | package websocket |
| 8 | |
| 9 | import "io" |
| 10 | |
| 11 | func (c *Conn) read(n int) ([]byte, error) { |
| 12 | p, err := c.br.Peek(n) |
| 13 | if err == io.EOF { |
| 14 | err = errUnexpectedEOF |
| 15 | } |
| 16 | if len(p) > 0 { |
| 17 | // advance over the bytes just read |
| 18 | io.ReadFull(c.br, p) |
| 19 | } |
| 20 | return p, err |
| 21 | } |