From 2a165c2e32b260d4c3bac77f416268d93f3ccfe2 Mon Sep 17 00:00:00 2001 From: I-yang Chen Date: Mon, 24 Apr 2017 14:10:16 -0700 Subject: [PATCH] decoding response content so it can be json loaded in python 3 without simplejson --- sailthru/sailthru_client.py | 2 +- sailthru/sailthru_response.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sailthru/sailthru_client.py b/sailthru/sailthru_client.py index e5102eb..917ddf3 100644 --- a/sailthru/sailthru_client.py +++ b/sailthru/sailthru_client.py @@ -569,7 +569,7 @@ def receive_verify_post(self, post_params): send_response = self.get_send(post_params['send_id']) try: - send_body = send_response.get_body() + send_body = send_response.get_body(as_dictionary=False) send_json = json.loads(send_body) if 'email' not in send_body: return False diff --git a/sailthru/sailthru_response.py b/sailthru/sailthru_response.py index 78c12a5..fdb42f1 100644 --- a/sailthru/sailthru_response.py +++ b/sailthru/sailthru_response.py @@ -11,7 +11,7 @@ def __init__(self, response): self.json_error = None try: - self.json = json.loads(response.content) + self.json = json.loads(response.content.decode()) except ValueError as e: self.json = None self.json_error = str(e) @@ -23,7 +23,7 @@ def get_body(self, as_dictionary=True): if as_dictionary: return self.json else: - return self.response.content + return self.response.content.decode() def get_response(self): return self.response