Why does a comet need an encoding reaction with an encoding?

I read several articles about Comet technology. They all mentioned that a long-term HTTP response should be Transfer-Encoding: chunked. I wonder why this should be encoded. If the response is not encoded, client-side javascript can still read and parse the edited text, right?

Is there any special reason why a comet response should be encoded?

+3
source share
1 answer

The interlaced encoding response is used when the length of the response is unknown until the response is complete. An empty fragment indicates the end of the response. This is the only way that a client can be notified of the completion of a response.

All this goes well with comets. You send the first piece when you receive a request. You can also send additional β€œheartbeats” while waiting for the action to complete. An empty fragment will notify the client of the completion of the response.

+7
source

Source: https://habr.com/ru/post/1711900/


All Articles