I'm using the following to serve a file from GS through PHP App Engine:
google\appengine\api\cloud_storage\CloudStorageTools::serve
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)
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?
I have experience with App Engine but used with Python, but I hope this is useful.
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.
This ensures there are no mistakes on the value and it will be the length of the absolute final response sent by App Engine.
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With