tests/soup.js
[gitlive] / tests / soup.js
index 53cdd7b..e376b25 100644 (file)
@@ -1,14 +1,36 @@
 #!/usr/bin/env seed
 
 Soup = imports.gi.Soup;
+GLib = imports.gi.GLib;
 
 var session = new Soup.SessionSync();
-
-
-
+File  = imports['../File.js'].File;
+
+var netrc = File.read(GLib.get_home_dir() + "/.netrc");
+var lines = [];
+netrc.split("\n").forEach(function(nl) {
+    var line = {};
+    var k = false
+   print(JSON.stringify(nl));
+
+    nl.replace(/\s+$/,'').replace(/^\s+/,'').split(/\s+/).forEach(function(kv) {
+        print(JSON.stringify(kv));
+
+        if (!k) {
+            k = kv;
+            return
+        }
+        line[k] = kv
+        k = false;
+   });
+   
+   lines[line.machine] = line;
+    
+});
+print(JSON.stringify(lines));
 
 // Soup.URI is a struct.
-var uri = new Soup.URI.c_new("http://www.roojs.com/admin.php");
+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\"");
@@ -27,4 +49,4 @@ var status = session.send_message(msg);
 //)
 print(status);
 
-//print(msg.response_body.data);
+print(msg.response_body.data);