tests/soup.js
[gitlive] / tests / soup.js
1 #!/usr/bin/env seed
2
3 Soup = imports.gi.Soup;
4 Netrc = imports['../Netrc.js'].Netrc;
5
6 GLib = imports.gi.GLib;
7
8 var session = new Soup.SessionSync();
9 File  = imports['../File.js'].File;
10
11 Netrc.load();
12  
13 // Soup.URI is a struct.
14 var uri = new Soup.URI.c_new("http://www.roojs.com/admin.php/Roo/Events");
15 //var uri = new Soup.URI.c_new("http://www.roojs.com/head.php");
16
17 var msg = new Soup.Message({method:"POST", uri:uri});
18 //var msg = new Soup.Message({method:"GET", uri:uri});
19
20 // post..
21 buftxt =  "remarks=test";
22  
23 msg.set_request('application/x-www-form-urlencoded', Soup.MemoryUse.COPY, buftxt, buftxt.length)
24
25
26 var auth = new Soup.Auth.c_new(Soup.AuthBasic.type, msg, "Basic realm=\"Test\"");
27 print(auth);
28 print(auth.authenticate);
29 var authvals = authdata['git.roojs.com'];
30 auth.authenticate(authvals.login ,authvals.password);
31 var authmsg = auth.get_authorization(msg);
32 print(authmsg);
33 msg.request_headers.append('Authorization', authmsg)
34
35 //request.headers_append...
36 var status = session.send_message(msg);
37 // session.queue_message(function(ses, msg) {
38 //
39 //}
40 //)
41 print(status);
42
43 print(msg.response_body.data);