When I enter the URL http://localhost:8080/?noheaders.c in a Web browser, G-WAN seems to be blocking during 20 seconds before responding, whatever the browser (IE, Chrome, or Firefox).
-
What is causing this?
-
How can we avoid that?
Thanks for your insights.
This has nothing to do with G-WAN: this is an HTTP protocol issue.
The
noheaders.cscript demonstrates how to generate aJSONreply without HTTP headers. This reply is supposed to be fetched byJavascriptcode running in the browser, see thecomet.cexample for an illustration.When the “Content-Length”
HTTP headeris 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 headeris 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).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.