I have a script which when accessed with the HTTP protocol will send some data, pause for a few seconds, then send some more data, repeating until all the data is sent.
When I access it in
curl, it behaves as expected, and sends the data piece by piece. However, if i try to access the page in a browser, nothing is displayed on the screen until the entire script has finished running, several seconds later.
You can observe this behavior (temporarily) by accessing the URL
Then try the URL again in a browser and notice how the script waits for about 7 seconds before it loads anything, even though it should have access to the first lines immediately.
What is the source of this behavior?
It's written in NodeJS, and I put it up on GitHub for reference. However, in this case I'm assuming the language involved is irrelevant (which is why I asked it on SuperUser instead of StackOverflow, and any script which has a "pause" before sending data will behave in a similar fashion.