1 XObject = imports.XObject.XObject;
3 Soup = imports.gi.Soup;
5 var XMLHttpRequest = function (cfg) {
6 if (typeof(cfg) == 'object') {
14 XMLHttpRequest.prototype = {
26 withCredentials : false,
45 open : function ( method, url, async, user, password)
47 async = async || false;
49 password = password || false;
51 this._session = async ? new Soup.SessionAsync() : new Soup.SessionSync();
53 var uri = new Soup.URI.c_new(url);
54 this._message = new Soup.Message({method: method, uri:uri});
57 if (user || password) {
59 password = password || '';
60 var auth = new Soup.Auth.c_new(
63 "Basic realm=\"Test\"");
67 auth.authenticate(user,password);
68 var authmsg = auth.get_authorization(this._message);
70 this._message.request_headers.append(
71 'Authorization', authmsg);
78 setRequestHeader : function ( header, value)
80 _this.message.request_headers.append(headers, value)
83 overrideMimeType : function ( mime)
91 this._message.set_request('application/x-www-form-urlencoded', Soup.MemoryUse.COPY, data, data.length)
95 this._session.queue_message(this._message, function(ses, msg) {
96 // doc's say we get here after we have sent the data..
98 //print("got queue callback");
99 //_t._session.unpause_message(this._message);
100 _t.responseText = _t._message.response_body.data;
103 if (_t.onreadystatechange) {
104 _t.onreadystatechange();
112 var status = this._session.send_message(this._message);
113 this.responseText = this._message.response_body.data;
115 if (_t.onreadystatechange) {
116 _t.onreadystatechange();
126 // response (all readonly...)
129 //readonly attribute any response
130 responseText : false,
132 responseType : false,
135 getResponseHeader : function( header)
139 getAllResponseHeaders : function ()