Allow empty body without Content-Type; Introduce response.empty() (#1736)
This commit is contained in:
committed by
Stephen Sadowski
parent
3f6a978328
commit
fccbc1adc4
@@ -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""
|
||||
|
||||
Reference in New Issue
Block a user