forked from billywhizz/node-httpclient
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.js
More file actions
31 lines (25 loc) · 1.12 KB
/
example.js
File metadata and controls
31 lines (25 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var sys = require("sys");
var httpcli = require("./lib/httpclient");
var url = "http://www.betdaq.com/UI/Default.aspx";
var surl = "https://www.betdaq.com/UI/Default.aspx";
function verifyTLS(request) {
sys.puts(sys.inspect(request, true, 10));
return true;
}
var client = new httpcli.httpclient();
// a simple http request with default options (gzip off, keepalive off, https off)
client.perform(url, "GET", function(result) {
sys.puts(sys.inspect(result, true, 10));
});
var client2 = new httpcli.httpclient();
// nested calls with gzip compression and keep-alive
client2.perform(url, "GET", function(result) {
sys.puts(sys.inspect(result, true, 10));
client2.perform(url, "GET", function(result) {
sys.puts(sys.inspect(result, true, 10));
// https request with callback handling of certificate validation
client2.perform(surl, "GET", function(result) {
sys.puts(sys.inspect(result, true, 10));
}, null, {"Accept-Encoding" : "none,gzip", "Connection" : "close"}, verifyTLS);
}, null, {"Accept-Encoding" : "none,gzip", "Connection" : "Keep-Alive"});
}, null, {"Accept-Encoding" : "none,gzip", "Connection" : "Keep-Alive"});