开发者

How to enable transfer-encoding:chunked in Java on AppEngine

开发者 https://www.devze.com 2023-02-16 01:17 出处:网络
I have done a number of google searches on this topic, but haven\'t been able to find anything (other than confirmation that AppEngine ignores calls to \'resp.setHeader(\"transfer-encoding\", xxxx)\'.

I have done a number of google searches on this topic, but haven't been able to find anything (other than confirmation that AppEngine ignores calls to 'resp.setHeader("transfer-encoding", xxxx)'.

My issue is that I have a server process that takes a little bit of time to complete (~3second avg), but which produces results in a continous stream (ie the first data object is ready after just 10ms).

Currently, the server buffers the response, and then spits the whole lot down to the client for display. Whilst this works, it isn't a brilliant user experience, as the user has to wait for the whole process to finish before they are able to see the first results...

I believe that using a chunked transfer would solve this, as I would be able to send the first response to the client immediately (and stream subsequent data as soon as it became available), giving a much better idea of progress etc.

My problem is that I can't work out how to enable chunked transfer.

Googling for chunked transfer and app engine mostly turns up posts from people wanting to disable chunked transfer from the blobstore, or posts stating that chunked transfer is enabled by default. However, my testing to date has indicated that, at least for my application, this is not true.

Likewise, non-app-engine references talk about setting the 'transfer-encoding' content header - but this is explicitly ignored on AppEngine (at least, it is according to the python docs - not found anything on the Java side, that states it explicitly, but it didn't work 开发者_开发技巧when I tested it either).

lastly, I have already tried flushing the respose object, getting the response writer and flushing, getting the response output stream and flushing, etc. made no difference.

So - my question is: how do I enable chunked transfer?


Appengine does not support streaming of responses. The whole response must be returned at once.

App Engine does not support sending data to the client, performing more calculations in the application, then sending more data. In other words, App Engine does not support "streaming" data in response to a single request.

See Responses Java

0

精彩评论

暂无评论...
验证码 换一张
取 消