From fb1ca07bc102ba78280bcbf2f227a3cbcd64186d Mon Sep 17 00:00:00 2001 From: Guy D Date: Sun, 10 Dec 2017 14:46:42 +0200 Subject: [PATCH] Supporting the case where there is error and DownloadCoded is enabled --- coreapi/transports/http.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coreapi/transports/http.py b/coreapi/transports/http.py index a548024..ec34cea 100644 --- a/coreapi/transports/http.py +++ b/coreapi/transports/http.py @@ -268,6 +268,8 @@ def _coerce_to_error(obj, default_title): return Error(title=default_title, content={'messages': obj}) elif obj is None: return Error(title=default_title) + elif hasattr(obj, "read"): + return Error(title=default_title, content={'messages': obj.read().decode("utf-8")}) return Error(title=default_title, content={'message': obj})