What is causing this?
This has nothing to do with G-WAN: this is an HTTP protocol issue.
The noheaders.c
script demonstrates how to generate a JSON
reply without HTTP headers. This reply is supposed to be fetched by Javascript
code running in the browser, see the comet.c
example for an illustration.
When the "Content-Length" HTTP header
is present, browsers don't have to wait more than the time needed to load the specified amount of data.
The lack of a "Content-Length" HTTP header
is forcing Internet Browsers to guess when to stop waiting for more data (they wait for a while, without displaying anything, and then, after a timeout, they display everything they have received).
How can we avoid that?
The mechanism is explained in this other example using streaming and the chunked encoding to prevent the browser from blocking.
No "Content-Length" is provided because here the length is not known in advance. The chunked-encoding tells browsers that, until they receive and End-Of-Reply marker, they should read more data.