tests/soup.js
[gitlive] / tests / soup.js
1 #!/usr/bin/env seed
2
3 Soup = imports.gi.Soup;
4 GLib = imports.gi.GLib;
5
6 var session = new Soup.SessionSync();
7 File  = imports['../File.js'].File;
8
9 var netrc = File.read(GLib.get_home_dir() + "/.netrc");
10 print(netrc);
11
12 // Soup.URI is a struct.
13 var uri = new Soup.URI.c_new("http://www.roojs.com/admin.php/Roo/person");
14 var msg = new Soup.Message({method:"GET", uri:uri});
15
16 var auth = new Soup.Auth.c_new(Soup.AuthBasic.type, msg, "Basic realm=\"Test\"");
17 print(auth);
18 print(auth.authenticate);
19 auth.authenticate('aaaa','bbbb');
20 var authmsg = auth.get_authorization(msg);
21
22 msg.request_headers.append('Authorization', authmsg + '==')
23
24 //request.headers_append...
25 var status = session.send_message(msg);
26 // session.queue_message(function(ses, msg) {
27 //
28 //}
29 //)
30 print(status);
31
32 print(msg.response_body.data);