学堂 学堂 学堂公众号手机端

tornado AsyncHTTPClient() delete方法

lewis 6年前 (2019-05-10) 阅读数 12 #技术

报错信息:tornado\simple_httpclient.py", line 365, in run raise KeyError("unknown method %s" % self.request.method)

KeyError: 'unknown method delete'

解决方案:需要在调用时设置allow_nonstandard_methods=True


async def _do_action(self, **kwargs):
http_client = AsyncHTTPClient()
response = await http_client.fetch(kwargs.get('url'), method=kwargs.get('method'), raise_error=False,
body=kwargs.get('data'), headers=kwargs.headers,
request_timeout=kwargs.request_timeout,allow_nonstandard_methods=True)

return response.body

方法默认allow_nonstandard_methods=True

版权声明

本文仅代表作者观点,不代表博信信息网立场。

热门