Re: [XHR] Content-Length header for data: URLs

On Thu, Sep 19, 2013 at 6:24 PM, Hallvord Steen <hsteen@mozilla.com> wrote:

> > Are you saying it's possible to use 'data:' requests with XHR? What's
> > the sense for this? The data is already on the client...
>
> You can indeed, in browsers that (more or less) support spec:
> http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#data:-urls-and-http
>
> Don't know if there are that many use cases but I guess you could easily
> get a blob from a base64-string, or use it as a more or less convenient XML
> parser if all you have is a URL-encoded string of XML source text.. :-)
>

The use is where you want to expose a script API that takes a URL.  Your
API can use XHR on the URL without caring if it's a data: URL, and the user
can pass in a data: URL without caring that the innards of the script
happen to use XHR with it.  It's ordinary layering--the user of your API
shouldn't have to care about those things, and you (the author of the API)
shouldn't have to worry about avoiding XHR because it'll break data: URLs.

-- 
Glenn Maynard

Received on Thursday, 19 September 2013 23:44:54 UTC