From 947c0f48e43209aa74244c8320150e0fc08d825e Mon Sep 17 00:00:00 2001 From: Benoit Gschwind Date: Thu, 12 Jul 2018 15:31:03 +0200 Subject: [PATCH] Ensure exception provide the correct Content-Type Because XML is 'text/*' we should set the charset in content type header this the pupose of this changes. --- pywps/exceptions.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pywps/exceptions.py b/pywps/exceptions.py index e174de422..0babfcff5 100644 --- a/pywps/exceptions.py +++ b/pywps/exceptions.py @@ -12,6 +12,7 @@ """ +from werkzeug.wrappers import Response from werkzeug.exceptions import HTTPException from werkzeug._compat import text_type from werkzeug.utils import escape @@ -50,10 +51,6 @@ def name(self): """The status name.""" return self.__class__.__name__ - def get_headers(self, environ=None): - """Get a list of headers.""" - return [('Content-Type', 'text/xml')] - def get_description(self, environ=None): """Get the description.""" if self.description: @@ -61,9 +58,8 @@ def get_description(self, environ=None): else: return '' - def get_body(self, environ=None): - """Get the XML body.""" - return text_type(( + def get_response(self, environ=None): + doc = text_type(( u'\n' u'\n' u'\n' # noqa @@ -78,6 +74,7 @@ def get_body(self, environ=None): 'name': escape(self.name), 'description': self.get_description(environ) }) + return Response(doc, self.code, mimetype='text/xml') class InvalidParameterValue(NoApplicableCode):