Merge pull request #430 from aquacash5/master
Added raw response for bag o' bytes responses
This commit is contained in:
commit
d44edb5930
|
@ -154,15 +154,32 @@ def json(body, status=200, headers=None, **kwargs):
|
||||||
status=status, content_type="application/json")
|
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.
|
Returns response object with body in text format.
|
||||||
:param body: Response data to be encoded.
|
:param body: Response data to be encoded.
|
||||||
:param status: Response code.
|
:param status: Response code.
|
||||||
:param headers: Custom Headers.
|
:param headers: Custom Headers.
|
||||||
|
:param content_type:
|
||||||
|
the content type (string) of the response
|
||||||
"""
|
"""
|
||||||
return HTTPResponse(body, status=status, headers=headers,
|
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):
|
def html(body, status=200, headers=None):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user