W3C home > Mailing lists > Public > ietf-http-wg@w3.org > April to June 2006

Re: Extension methods & XMLHttpRequest

From: Jamie Lokier <jamie@shareable.org>
Date: Mon, 12 Jun 2006 20:33:51 +0100
To: Stefan Eissing <stefan.eissing@greenbytes.de>
Cc: Julian Reschke <julian.reschke@gmx.de>, David Morris <dwm@xpasc.com>, ietf-http-wg@w3.org
Message-ID: <20060612193351.GB18718@mail.shareable.org>

Stefan Eissing wrote:
> I am sure that David can speak for himself, however the benefits of  
> IFrames over XmlHttpRequest are discussed in the "Comet" web pattern.  
> For example here:
> http://softwareas.com/index.php?s=comet

Funnily enough I was working through the details last night of
streaming messages to a client asynchronously.  (For example, like in
an instant message client, live news feed, shared whiteboard, etc.)

I came to the same conclusion as Comet: you have to use an IFRAME and
stream SCRIPT elements to it as each message is to be transferred.

Technologically it doesn't look pretty, but the mess is really
confined to one small thing: the code responsible for streaming
messages.  The rest of the application code is decoupled from this

It's interesting that this method is quite portable, works with very
old browsers, and is close to optimal in terms of network performance
and responsiveness.  (Compare with polling using XHR every few
seconds, as some people do).

There's actually nothing to be gained by using XMLHttpRequest on
browsers that support incrementally viewing the response (not IE), and
plenty to lose.

Ways in which you lose with XHR are: you'd still have to poll the XHR
object often; xhr.responseText might get progressively slower if it
always re-parses the received bytes into characters; you can't easily
tell if a browser's XHR is incremental except by sniffing the User-Agent.

(Btw, Gecko and Microsoft's XHR objects do support some kind of stream
interface, but I don't think they're accessible from Javascript.)

Note that the IFRAME + streamed SCRIPT method is only needed for web
apps that need to receive asynchronous messages from the server -
without continuously polling the server.  XHR is fine for apps which
only need to fetch something immediately following a user action.

It leaves me wondering if XHR should be extended to support streaming
properly, in a standard way...

Unfortunately the whole idea is quite at odds with the "official" way
HTTP and HTML are supposed to be used.  But then we lost that as soon
as the DOM become accessible, and people noticed you can make fancy
interactive applications.

-- Jamie
Received on Monday, 12 June 2006 19:34:06 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 11:10:39 UTC