Google App Engine提供Content-Length标头 [英] Google App Engine serve Content-Length header

查看:106
本文介绍了Google App Engine提供Content-Length标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下内容通过PHP App Engine从GS提供文件:

I'm using the following to serve a file from GS through PHP App Engine:

google\appengine\api\cloud_storage\CloudStorageTools::serve

这不会设置Content-Length标头,并且App Engine不允许脚本手动设置该标头. ( https://cloud.google.com/appengine/docs/python/how-requests-are-handled#headers_removed )

This doesn't set the Content-Length header and App Engine doesn't allow that header to be set manually by a script. (https://cloud.google.com/appengine/docs/python/how-requests-are-handled#headers_removed)

如何设置Content-Length标头,以便用户在开始下载文件时就知道文件有多大?

How can I set the Content-Length header so the user has an idea of how large the file is when they start to download it?

推荐答案

我有使用App Engine的经验,但已在Python上使用过,但我希望这对您有用.

I have experience with App Engine but used with Python, but I hope this is useful.

如果您手动设置Content-Length标头,则App Engine将删除它,但是会在响应发送到客户端之前自动设置Content-Length标头.

App Engine will remove the Content-Length header if you set it manually, but it will automatically set it before the response is sent to the client.

这可确保该值没有错误,这将是App Engine发送的绝对最终响应的长度.

This ensures there are no mistakes on the value and it will be the length of the absolute final response sent by App Engine.

我已经用一个新的简单应用程序对此进行了测试,方法是手动设置一个错误的大小,将其留为空白并设置正确的大小.在所有三个测试中,App Engine都会将正确的Content-Length返回给客户端.

I have tested this with a new simple app by setting a wrong size manually, leaving it blank and setting the correct size. In all three tests, the correct Content-Length is returned to the client by App Engine.

您是否已从客户端进行了测试,以查看标头是否存在且正确?

Have you tested from the client to see if the header is present and correct?

我希望这有助于澄清,尽管App Engine将删除标头,但会自动将其设置为正确的值.

I hope this helps clarify that while App Engine will remove the header if you set it, it will set it to the correct value automatically.

这篇关于Google App Engine提供Content-Length标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆