Allow empty body without Content-Type; Introduce response.empty() (#1736)

This commit is contained in:
Liran Nuna
2019-12-23 12:16:53 -08:00
committed by Stephen Sadowski
parent 3f6a978328
commit fccbc1adc4
2 changed files with 27 additions and 4 deletions

View File

@@ -21,6 +21,7 @@ from sanic.response import (
raw,
stream,
)
from sanic.response import empty
from sanic.server import HttpProtocol
from sanic.testing import HOST, PORT
@@ -591,3 +592,13 @@ def test_raw_response(app):
request, response = app.test_client.get("/test")
assert response.content_type == "application/octet-stream"
assert response.body == b"raw_response"
def test_empty_response(app):
@app.get("/test")
def handler(request):
return empty()
request, response = app.test_client.get("/test")
assert response.content_type is None
assert response.body == b""