0

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.

Eli
  • 106
  • 7

1 Answers1

1

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.

Gil
  • 3,279
  • 1
  • 15
  • 25