Browse Source

Fix reading the streamID sign

In v3 the stream is an int16 not a uint16, int v2 ensure we handle
the sign of the int8 correctly.
Chris Bannister 10 năm trước cách đây
mục cha
commit
395c7d05e3
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      frame.go

+ 2 - 2
frame.go

@@ -297,11 +297,11 @@ func readHeader(r io.Reader, p []byte) (head frameHeader, err error) {
 
 	head.flags = p[1]
 	if version > protoVersion2 {
-		head.stream = int(readShort(p[2:]))
+		head.stream = int(int16(p[2])<<8 | int16(p[3]))
 		head.op = frameOp(p[4])
 		head.length = int(readInt(p[5:]))
 	} else {
-		head.stream = int(p[2])
+		head.stream = int(int8(p[2]))
 		head.op = frameOp(p[3])
 		head.length = int(readInt(p[4:]))
 	}