Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

HTTPのレスポンスを取得


function hello(){
var uri = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURI);
uri.spec = "http://www.google.com/";

var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService( Components.interfaces.nsIIOService );
var channel = ios.newChannelFromURI(uri);

var observer = {
onStreamComplete: function(loader, cx, status, len, result) {
alert(String.fromCharCode.apply(this, result));
}
};


var sl = Components.classes["@mozilla.org/network/stream-loader;1"]
.createInstance(Components.interfaces.nsIStreamLoader);

sl.init(channel, observer, null);
}