X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=tests%2Fsoup.js;h=50eb2d1a1fa03f77a2f773197b6d0e5ca9d4a72a;hb=HEAD;hp=de8fb2ee26dc7c6a7307a3d7218365b449881cf3;hpb=b912d2d68cf4ec5848311f242c99e87f86f2b683;p=gitlive diff --git a/tests/soup.js b/tests/soup.js index de8fb2ee..50eb2d1a 100644 --- a/tests/soup.js +++ b/tests/soup.js @@ -1,50 +1,44 @@ #!/usr/bin/env seed +XMLHttpRequest = imports['../XMLHttpRequest.js'].XMLHttpRequest; +Netrc = imports['../Netrc.js'].Netrc; +File = imports['../File.js'].File; +Gtk = imports.gi.Gtk; -Soup = imports.gi.Soup; -GLib = imports.gi.GLib; +Gtk.init (null, null); -var session = new Soup.SessionSync(); -File = imports['../File.js'].File; +// sa + + +var authvals = Netrc.forHost('git.roojs.com'); -var netrc = File.read(GLib.get_home_dir() + "/.netrc"); -var authdata = {}; -netrc.split("\n").forEach(function(nl) { - var line = {}; - var k = false - - nl.replace(/\s+$/,'').replace(/^\s+/,'').split(/\s+/).forEach(function(kv) { - - if (!k) { - k = kv; - return - } - line[k] = kv - k = false; - }); - - authdata[line.machine] = line; + +//print(JSON.stringify(imports['../XMLHttpRequest.js'], null,4)); + +var x = new XMLHttpRequest({ + onreadystatechange : function() + { + print("GOT " + x.responseText); + + + } + }); +print(JSON.stringify(x)); + +//"http://www.roojs.com/admin.php/Roo/Events" POST +x.open("GET", "http://www.roojs.com/admin.php/Roo/Events?limit=3", true, authvals.login ,authvals.password) +//buftxt = "remarks=test"; + + +x.send(); + +Gtk.main(); +//var msg = new Soup.Message({method:"GET", uri:uri}); + +// post.. -// Soup.URI is a struct. -var uri = new Soup.URI.c_new("http://www.roojs.com/admin.php/Roo/person"); -var msg = new Soup.Message({method:"GET", uri:uri}); - -var auth = new Soup.Auth.c_new(Soup.AuthBasic.type, msg, "Basic realm=\"Test\""); -print(auth); -print(auth.authenticate); -var authvals = authdata['git.roojs.com']; -auth.authenticate(authvals.login ,authvals.password); -var authmsg = auth.get_authorization(msg); -print(authmsg); -msg.request_headers.append('Authorization', authmsg + '==') - -//request.headers_append... -var status = session.send_message(msg); // session.queue_message(function(ses, msg) { // //} //) -print(status); - -print(msg.response_body.data);