Re: faking HTTP with a socket channel
On Tue, 12 Aug 2008, Neil Coffey wrote:
Roedy Green wrote:
8. Then various images come back from the server on the original
socket or on their own sockets so they can arrive simultaneously.
OK, although you make it sound as though one request per connection is
the desirable case; from the server's point of view, it definitely
isn't. As of HTTP 1.1, the default behaviour is to perform multiple
requests per socket if possible. (It isn't when the server can't
calculate the size of the returned data in advance, e.g. with many
dynamic web pages.)
To expand on that, if the server has an output buffer, and the generated
page is smaller than the buffer, then it can collect the whole thing in
the buffer, work out the size, send a Content-Length header, and reuse the
connection afterwards. If it's bigger than the buffer, it can't do this -
i think that's what you were getting at with "many dynamic web pages".
What you might not be aware of is the chunked encoding:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1
http://developers.sun.com/mobility/midp/questions/chunking/
Which allows the transfer of unknown-length data across an HTTP connection
without having to close the stream afterwards. Thus, even for dynamic
pages bigger than the buffer, the connection can be reused.
tom
--
As a matter of fact, it is estimated that 10% of all meth labs explode.