我的REST API的消费者说有时我返回400 Bad Request – 客户端发送的请求在语法上是不正确的.错误.
我的应用程序(Python / Flask)日志似乎没有捕获这个,我的webserver / Nginx也没有记录.
编辑:我想尝试在Flask中导致400个错误请求以进行调试.我怎样才能做到这一点?
根据James的建议,我添加了类似于以下内容:
@app.route('/badrequest400)
def bad_request():
return abort(400)
当我调用它时,flask返回以下HTML,它不使用“客户端发送的请求在语法上不正确”行:
400 Bad RequestBad Request
The browser (or proxy) sent a request that this server could not understand.
(我不确定为什么它不包括< body>标签.
在我看来,400错误消息有不同的变化.例如,如果我将cookie设置为长度为50,000的值(使用Interceptor with Postman),我将从Flask获得以下错误:
Bad RequestBad Request
Error parsing headers: 'limit request headers fields size'
有没有办法让Flask通过400个错误的不同变化?