tests/soup.js
[gitlive] / tests / soup.js
index 97e50ab..1e9ad57 100644 (file)
@@ -7,15 +7,13 @@ var session = new Soup.SessionSync();
 File  = imports['../File.js'].File;
 
 var netrc = File.read(GLib.get_home_dir() + "/.netrc");
-var lines = [];
+var authdata = {};
 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));
-
+     
+    nl.replace(/\s+$/,'').replace(/^\s+/,'').split(/\s+/).forEach(function(kv) {
+      
         if (!k) {
             k = kv;
             return
@@ -23,23 +21,25 @@ netrc.split("\n").forEach(function(nl) {
         line[k] = kv
         k = false;
    });
-   
-   lines[line.machine] = line;
+       
+   authdata[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/Roo/person");
+var uri = new Soup.URI.c_new("http://www.roojs.com/admin.php/Roo/person?limit=5");
+//var uri = new Soup.URI.c_new("http://www.roojs.com/head.php");
+
 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);
-auth.authenticate('aaaa','bbbb');
+var authvals = authdata['git.roojs.com'];
+auth.authenticate(authvals.login ,authvals.password);
 var authmsg = auth.get_authorization(msg);
-
-msg.request_headers.append('Authorization', authmsg + '==')
+print(authmsg);
+msg.request_headers.append('Authorization', authmsg)
 
 //request.headers_append...
 var status = session.send_message(msg);