commit 123c73b4e06c89781543dfcba55581d6a3931129 parent e18eae1e465a90f854fc55a4676c41b2f897bd82 Author: Natalie Pendragon <natpen@natpen.net> Date: Sat, 14 Mar 2020 10:09:59 -0400 Handle binary responses Diffstat:
M | gusmobile/client.py | | | 13 | ++++++++----- |
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/gusmobile/client.py b/gusmobile/client.py @@ -147,11 +147,14 @@ def fetch(url): return # Read the response body over the network body = f.read() - try: - content = codecs.decode(body, charset) - except: - # print("ERROR: problem decoding content with %s charset" % charset) - return + if mime.startswith("text/"): + try: + content = codecs.decode(body, charset) + except: + # print("ERROR: problem decoding content with %s charset" % charset) + return + else: + content = body return Response( content=content, content_type=mime,