def test_expect_default_handler_unknown(loop, test_client):
"""Test default Expect handler for unknown Expect value.
A server that does not understand or is unable to comply with any of
the expectation values in the Expect field of a request MUST respond
with appropriate error status. The server MUST respond with a 417
(Expectation Failed) status if any of the expectations cannot be met
or, if there are other problems with the request, some other 4xx
status.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.20
"""
@asyncio.coroutine
def handler(request):
yield from request.post()
pytest.xfail('Handler should not proceed to this point in case of '
'unknown Expect header')
app = web.Application()
app.router.add_post('/', handler)
client = yield from test_client(app)
resp = yield from client.post('/', headers={'Expect': 'SPAM'})
assert 417 == resp.status
评论列表
文章目录