From 9868c0cc95a80e1d4b0f42b159c9f6e4002ef82b Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Apr 27 2020 01:07:15 +0000 Subject: util/log: Convert properly between str and bytearray Most of this file operates on strings, but there are a couple of places operating on bytes, and we need to handle switching back and forth between the two types in this case. Signed-off-by: Neal Gompa --- diff --git a/ipsilon/util/log.py b/ipsilon/util/log.py index 9b36c73..f35602f 100644 --- a/ipsilon/util/log.py +++ b/ipsilon/util/log.py @@ -179,7 +179,7 @@ def log_request_response(): f = StringIO() for chunk in body: - f.write(chunk) + f.write(chunk.decode('utf-8')) string = f.getvalue() f.close() @@ -244,9 +244,9 @@ def log_request_response(): if response.stream: f.write(indent_text("body omitted because response is streaming\n", 2)) else: - response.body = collapse_body(response.body) + response.body = collapse_body(response.body).encode('utf-8') for chunk in response.body: - f.write(indent_text(chunk, 2)) + f.write(indent_text(chunk.decode('utf-8'), 2)) string = f.getvalue() f.close()