3 Soup = imports.gi.Soup;
4 GLib = imports.gi.GLib;
6 var session = new Soup.SessionSync();
7 File = imports['../File.js'].File;
9 var netrc = File.read(GLib.get_home_dir() + "/.netrc");
11 netrc.split("\n").forEach(function(nl) {
14 nl.split(/\s+/).forEach(function(kv) {
23 lines[line.machine] = line;
26 print(JSON.stringify(lines));
28 // Soup.URI is a struct.
29 var uri = new Soup.URI.c_new("http://www.roojs.com/admin.php/Roo/person");
30 var msg = new Soup.Message({method:"GET", uri:uri});
32 var auth = new Soup.Auth.c_new(Soup.AuthBasic.type, msg, "Basic realm=\"Test\"");
34 print(auth.authenticate);
35 auth.authenticate('aaaa','bbbb');
36 var authmsg = auth.get_authorization(msg);
38 msg.request_headers.append('Authorization', authmsg + '==')
40 //request.headers_append...
41 var status = session.send_message(msg);
42 // session.queue_message(function(ses, msg) {
48 print(msg.response_body.data);