This commit is contained in:
@@ -187,21 +187,14 @@ def _detect_xerial_stream(payload):
|
||||
The version is the version of this format as written by xerial,
|
||||
in the wild this is currently 1 as such we only support v1.
|
||||
|
||||
Compat is there to claim the minimum supported version that
|
||||
Compat is there to claim the miniumum supported version that
|
||||
can read a xerial block stream, presently in the wild this is
|
||||
1.
|
||||
"""
|
||||
|
||||
if len(payload) > 16:
|
||||
magic = struct.unpack('!' + _XERIAL_V1_FORMAT[:8], bytes(payload)[:8])
|
||||
version, compat = struct.unpack('!' + _XERIAL_V1_FORMAT[8:], bytes(payload)[8:16])
|
||||
# Until there is more than one way to do xerial blocking, the version + compat
|
||||
# fields can be ignored. Also some producers (i.e., redpanda) are known to
|
||||
# incorrectly encode these as little-endian, and that causes us to fail decoding
|
||||
# when we otherwise would have succeeded.
|
||||
# See https://github.com/dpkp/kafka-python/issues/2414
|
||||
if magic == _XERIAL_V1_HEADER[:8]:
|
||||
return True
|
||||
header = struct.unpack('!' + _XERIAL_V1_FORMAT, bytes(payload)[:16])
|
||||
return header == _XERIAL_V1_HEADER
|
||||
return False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user