0

I'm trying to implement HTTP Streaming by using IHttpAsyncHandler and flushing.

Basically I'm flushing to the response every once and a while - saving the connection opened untill some timeout - and then the client should initiate another connection.

The flush indeed works and the client receives the flushes as they occur, however the response is getting aggregated. For example, if I send the following flushes:

"TextOnFlush1"
"TextOnFlush2"
"TextOnFlush3"

The client will get the following flushes (in the XMLHttpRequest.responseText):

"TextOnFlush1"
"TextOnFlush1""TextOnFlush2"
"TextOnFlush1""TextOnFlush2""TextOnFlush3"

As you can see eventually the client will have to handle with a very large message (which will contain all the previously flushes). Is there a way to work with the flush, but to clean the respone on each flush?

Notice that the response header contains this header : "Transfer-Encoding:chunked", which means that I should indeed get the content in chunks but instead I get the aggregated messages.

Tomer Peled
  • 3,571
  • 5
  • 35
  • 57
  • You are flushing the entire response again to the stream every time. – Fals Nov 23 '13 at 11:34
  • Each time I'm writing other text to the response. The first time "TextOnFlush1" , the second "TextOnFlush2" , etc. But the client recieves the aggregated messages each time, any way to workaround this? or it isn't possible to clear the response in between flushes? – Tomer Peled Nov 23 '13 at 12:15

1 Answers1

1

So there is no way to get the browser to clean the response on each flush - so it is a good practice to limit this msg size and to refresh the streaming message on large data once in a while.

Tomer Peled
  • 3,571
  • 5
  • 35
  • 57