Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions rabbitpy/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,20 @@ def _wait_for_content_frames(self, method_frame):
return self._on_interrupt_set()

error = False
body_value = bytes() if PYTHON3 else str()
while len(body_value) < header_value.body_size:

# To retrieve the message body we must concatenate the binary content
# of several frames. The recommended idiom for this differs
# in py3 and py2.
if PYTHON3:
body_value = bytearray()
else:
body_chunks = []
body_length_received = 0
body_total_size = header_value.body_size

while body_length_received < body_total_size:
body_part = self._wait_on_frame(CONTENT_BODY)

self._check_for_rpc_request(body_part)
if self._interrupt_is_set:
self._on_interrupt_set()
Expand All @@ -479,12 +490,16 @@ def _wait_for_content_frames(self, method_frame):
elif consuming and not self._consumers:
self._reject_inbound_message(method_frame)
error = True

if error:
return

body_value += body_part.value
if len(body_value) == header_value.body_size:
break
body_length_received += len(body_part.value)
if PYTHON3:
body_value += body_part.value
else:
body_chunks.append(body_part.value)

if not PYTHON3:
body_value = ''.join(body_chunks)

return self._create_message(method_frame, header_value, body_value)