Merge pull request #430 from aquacash5/master

Added raw response for bag o' bytes responses
This commit is contained in:
Eli Uriegas 2017-02-14 14:19:01 -06:00 committed by GitHub
commit d44edb5930

View File

@ -154,15 +154,32 @@ def json(body, status=200, headers=None, **kwargs):
status=status, content_type="application/json")
def text(body, status=200, headers=None):
def text(body, status=200, headers=None,
content_type="text/plain; charset=utf-8"):
"""
Returns response object with body in text format.
:param body: Response data to be encoded.
:param status: Response code.
:param headers: Custom Headers.
:param content_type:
the content type (string) of the response
"""
return HTTPResponse(body, status=status, headers=headers,
content_type="text/plain; charset=utf-8")
content_type=content_type)
def raw(body, status=200, headers=None,
content_type="application/octet-stream"):
"""
Returns response object without encoding the body.
:param body: Response data.
:param status: Response code.
:param headers: Custom Headers.
:param content_type:
the content type (string) of the response
"""
return HTTPResponse(body_bytes=body, status=status, headers=headers,
content_type=content_type)
def html(body, status=200, headers=None):