mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-16 07:15:24 +01:00
use 'zlib.decompressobj' to handle the 'faulty' compression correctly as suggested in https://github.com/ammaraskar/pyCraft/pull/68
This commit is contained in:
parent
0c64623696
commit
7eef61bfde
@ -2,7 +2,7 @@ from __future__ import print_function
|
||||
|
||||
from collections import deque
|
||||
from threading import Lock
|
||||
from zlib import decompress
|
||||
import zlib
|
||||
import threading
|
||||
import socket
|
||||
import time
|
||||
@ -437,7 +437,9 @@ class PacketReactor(object):
|
||||
if self.connection.options.compression_enabled:
|
||||
decompressed_size = VarInt.read(packet_data)
|
||||
if decompressed_size > 0:
|
||||
decompressed_packet = decompress(packet_data.read())
|
||||
decompressor = zlib.decompressobj()
|
||||
decompressed_packet = decompressor.decompress(
|
||||
packet_data.read())
|
||||
assert len(decompressed_packet) == decompressed_size, \
|
||||
'decompressed length %d, but expected %d' % \
|
||||
(len(decompressed_packet), decompressed_size)
|
||||
|
Loading…
Reference in New Issue
Block a user