Javascript – Google Apps HTTP Streaming with Python question


I got a little question here:

Some time ago I implemented HTTP Streaming using PHP code, something similar to what is on this page:

And I get data with very similar solution. Now I tried to use second code from this page (in Python), but no matter what I do, I receive responseText from python server after everything completes. Here are some python code:

print "Content-Type: application/x-www-form-urlencoded\n\n"

while i<4:
 print("Event: server-time<br>")
 print("data: %f<br>" % (time.time(),))

And here is Javascript Code:

ask = new XMLHttpRequest();"GET","/Chat",true);
if (ask.responseText) document.write(ask.responseText);

Anyone got idea what I do wrong ? How can I receive those damn messages one after another, not just all of them at the end of while loop? Thanks for any help here!


Main thing I forgot to add: server is google app server (i'm not sure is that google own implementation), here is a link with some explanation (i think uhh):

Best Solution

Its highly likely App Engine buffers output. A quick search found this:

The out stream buffers all output in memory, then sends the final output when the handler exits. webapp does not support streaming data to the client.

Related Question