Bug 13968

Summary: XMLHttpRequest on data:// URLs broken
Product: WebKit Reporter: Sridhar Gurivireddy <just1gb>
Component: XMLAssignee: Nobody <webkit-unassigned>
Severity: Normal CC: ap, tzik, youennf
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: PC   
OS: OS X 10.4   
Description Flags
HTML that does a XHR on data://URL none

Description Sridhar Gurivireddy 2007-06-01 11:52:09 PDT
xmlHttprequest on data:// URLs does not work in webkit nightly build

var req = new XMLHttpRequest();
 //var url = "http://www.google.com";
var url = 'data:text/html;charset=utf-8,%3C!DOCTYPE%20HTML%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20HTML%204.0%2F%2FEN%22%3E%0D%0A%3Chtml%20lang%3D%22en%22%3E%0D%0A%3Chead%3E%3Ctitle%3EEmbedded%20Window%3C%2Ftitle%3E%3C%2Fhead%3E%0D%0A%3Cbody%3E%3Ch1%3E42%3C%2Fh1%3E%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E%0D%0A';
req.open('GET', url, true);
req.onreadystatechange = function(aEvt) {
  if( req.readyState == 4 && req.status == 200) {
    var div_id = document.getElementById('xxx');
    div_id.innerHTML = req.responseText;
Comment 1 Sridhar Gurivireddy 2007-06-01 11:53:52 PDT
Created attachment 14826 [details]
HTML that does a XHR on data://URL

Add this file to a http:// server and launch in safari.
Comment 2 Alexey Proskuryakov 2007-06-01 13:21:39 PDT
This does not work in Firefox either, and handling of data:// URLs is not specified in draft XMLHttpRequest spec. Does this work in Internet Explorer?

I'm particularly suspicious about the "req.status == 200" check - status is HTTP-specific, and does not apply to other protocols.

Also, what are the use cases for this? I mean, instead of loading a data:// URL, one can just use a string literal.
Comment 3 Alexey Proskuryakov 2007-10-05 05:25:02 PDT
It seems that Opera is the only browser that supports XHR on data:// URLs, and this feature is unlikely to get into the spec. See the thread <http://lists.w3.org/Archives/Public/public-webapi/2007Oct/0001.html>.

Since no use cases were presented, I don't see any value in implementing this.
Comment 4 Taiju Tsuiki 2012-06-18 01:13:40 PDT
Could you reconsider this?
Now, Firefox and Opera supports XHR for data: URL and some APIs have interface to get content as data: URL. 
Comment 5 youenn fablet 2016-07-12 08:10:05 PDT

*** This bug has been marked as a duplicate of bug 109199 ***