Sfoglia il codice sorgente

websocket: fix Read behaviour in hybiFrameReader.Read

The contract for Read specifies that a caller should process n bytes of
data before handling an error value. The previous implementation may
have discarded the final data read from the underlying reader if err
was non nil.

Change-Id: I81547cd9ea62c4060f79523679beed6bbc6ccd95
Reviewed-on: https://go-review.googlesource.com/23534
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dave Cheney 9 anni fa
parent
commit
7553b97266
1 ha cambiato i file con 0 aggiunte e 3 eliminazioni
  1. 0 3
      websocket/hybi.go

+ 0 - 3
websocket/hybi.go

@@ -81,9 +81,6 @@ type hybiFrameReader struct {
 
 
 func (frame *hybiFrameReader) Read(msg []byte) (n int, err error) {
 func (frame *hybiFrameReader) Read(msg []byte) (n int, err error) {
 	n, err = frame.reader.Read(msg)
 	n, err = frame.reader.Read(msg)
-	if err != nil {
-		return 0, err
-	}
 	if frame.header.MaskingKey != nil {
 	if frame.header.MaskingKey != nil {
 		for i := 0; i < n; i++ {
 		for i := 0; i < n; i++ {
 			msg[i] = msg[i] ^ frame.header.MaskingKey[frame.pos%4]
 			msg[i] = msg[i] ^ frame.header.MaskingKey[frame.pos%4]