既然不允许 Content-Length 标头,是否可以在 GAE 应用程序中设置 blob 下载大小?

发布于 2024-10-09 04:30:16 字数 456 浏览 4 评论 0原文

几周前发布 AppEngine API 更新后,Python 响应类文档中出现了精彩的“不允许的 HTTP 响应标头”部分 此处,这解释了出于安全目的无法设置列出的标头。

这一切都很好,只是现在我所有的 blob 下载都有未知的长度,导致所有主要浏览器显示未知的长度进度指示器!可以说,用户(和我自己)发现这对于大型下载来说非常烦人,因为无法猜测下载将花费多长时间,或者可能会进行多长时间。我之前通过根据数据存储中 blob 的信息记录设置 Content-Length 标头修复了此问题,但现在不允许这样做,是否有其他方法可以实现此目的?任何想法非常感谢!

After the AppEngine API update that came out a few weeks ago, the wonderful "Disallowed HTTP Response Headers" section appeared in the Python Response class documentation here, which explains that the listed headers cannot be set for security purposes.

That is all well and good except that now all of my blob downloads have unknown lengths, causing all major browsers show unknown length progress indicators! Suffice it to say that users (and myself) find this quite annoying for large downloads, as there is no way to guess how long the download will take, or how far along they may be. I fixed this before by setting the Content-Length header based on the blob's info records in the datastore, but now that that is disallowed, is there another way to accomplish this? Any ideas much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Saygoodbye 2024-10-16 04:30:16

您的文件是否通过以下方式传输

Transfer-Encoding: Chunked

: 那么可以通过 HTTP 发送这些文件,而无需使用 Content-Length: 标头。请参阅 HTTP/1.1 RFC 上的分块传输编码。我想您应该能够为 get 等方法定义自己的处理程序,并使用 webapp.WSGIApplication 自己创建 HTTP 响应。奥托,阿德里安Holovaty 从未收到过同一问题的答案。

Are your files transferred with

Transfer-Encoding: Chunked

Then it is possible over HTTP to send these files without the Content-Length: header. See the HTTP/1.1 RFC on Chunked Transfer Coding. I guess you should be able to define your own handler for the methods such as get etc, and create yourself the HTTP responses using webapp.WSGIApplication. OTOH, Adrian Holovaty never received an answer to this same question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文