Skip to content

Commit 9f412cc

Browse files
author
Egor Panfilov
committed
Fix return format of Response._response
1 parent c07b12e commit 9f412cc

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/saml2/httputil.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ def __call__(self, environ, start_response, **kwargs):
5555

5656
def _response(self, message="", **argv):
5757
if self.template:
58-
return [self.template % message]
58+
message = self.template % message
5959
elif self.mako_lookup and self.mako_template:
6060
argv["message"] = message
6161
mte = self.mako_lookup.get_template(self.mako_template)
62-
return [mte.render(**argv)]
62+
message = mte.render(**argv)
63+
64+
if isinstance(message, six.string_types):
65+
# Note(JP): A WSGI app should always respond
66+
# with bytes, so at this point the message should
67+
# become encoded instead of passing a text object.
68+
return [message.encode()]
69+
elif isinstance(message, six.binary_type):
70+
return [message]
6371
else:
64-
if isinstance(message, six.string_types):
65-
# Note(JP): A WSGI app should always respond
66-
# with bytes, so at this point the message should
67-
# become encoded instead of passing a text object.
68-
return [message]
69-
elif isinstance(message, six.binary_type):
70-
return [message]
71-
else:
72-
return message
72+
return message
7373

7474
def add_header(self, ava):
7575
"""

0 commit comments

Comments
 (0)