gpt4 book ai didi

browser - 在 Flask 结果连接重置中上传大于 MAX_CONTENT_LENGTH 的文件

转载 作者:行者123 更新时间:2023-12-03 15:46:54 26 4
gpt4 key购买 nike

我试图限制上传文件的大小,我将 app.config['MAX_CONTENT_LENGTH'] 设置为我想要的最大值,

我使用此代码来显示错误。

@app.errorhandler(413)
def request_entity_too_large(error):
return 'File Too Large', 413

使用curl时,错误显示正确。
我使用 Firefox/Safari 进行了检查,在两者中我都收到了连接断开/重置的浏览器错误。

火狐
The connection was reset

The connection to the server was reset while the page was loading.

The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer's network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

苹果浏览器
Can't open the page
...server unexpectedly dropped the connection...

服务器登录所有这些请求
192.168.1.1 - - [23/May/2015 15:50:34] "POST / HTTP/1.1" 413 -

为什么错误不能正确显示?

最佳答案

这是Flask开发服务器的问题,不用担心。在生产服务器上运行应用程序将解决这个问题。
this snippet由 Armin Ronacher 发布,他说:

You might notice that if you start not accessing .form or .files on incoming POST requests, some browsers will honor this with a connection reset message. This can happen if you start rejecting uploads that are larger than a given size.

Some WSGI servers solve that problem for you, others do not. For instance the builtin Flask webserver is pretty dumb and will not attempt to fix this problem.


查看更新 here .

关于browser - 在 Flask 结果连接重置中上传大于 MAX_CONTENT_LENGTH 的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30414696/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com