File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -37,14 +37,21 @@ def write(self, data):
37
37
38
38
def read (self , sz ):
39
39
if not self .buf :
40
- hdr = self .s .recv (2 )
41
- assert len (hdr ) == 2
42
- fl , sz = struct .unpack (">BB" , hdr )
43
- assert fl == 0x82
44
- if sz == 126 :
40
+ while True :
45
41
hdr = self .s .recv (2 )
46
42
assert len (hdr ) == 2
47
- (sz ,) = struct .unpack (">H" , hdr )
43
+ fl , sz = struct .unpack (">BB" , hdr )
44
+ if sz == 126 :
45
+ hdr = self .s .recv (2 )
46
+ assert len (hdr ) == 2
47
+ (sz ,) = struct .unpack (">H" , hdr )
48
+ if fl == 0x82 :
49
+ break
50
+ print ("Got unexpected websocket record of type %x, skipping it" % fl )
51
+ while sz :
52
+ skip = self .s .recv (sz )
53
+ print ("Skip data:" , skip )
54
+ sz -= len (skip )
48
55
data = self .s .recv (sz )
49
56
assert len (data ) == sz
50
57
self .buf = data
You can’t perform that action at this time.
0 commit comments