conn_read.go 380 B

123456789101112131415161718
  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. // +build go1.5
  5. package websocket
  6. import "io"
  7. func (c *Conn) read(n int) ([]byte, error) {
  8. p, err := c.br.Peek(n)
  9. if err == io.EOF {
  10. err = errUnexpectedEOF
  11. }
  12. c.br.Discard(len(p))
  13. return p, err
  14. }