-
Notifications
You must be signed in to change notification settings - Fork 5
/
client.js
43 lines (39 loc) · 1022 Bytes
/
client.js
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
32
33
34
35
36
37
38
39
40
41
42
43
let request = require('request');
let http = require('http');
let agent = new http.Agent({
keepAlive: true,
});
let baseUrl = 'http://localhost:9666';
function getStatus() {
request.get(baseUrl + '/status', {
agent: agent
}, function (err, resp) {
if (err) {
throw err;
}
console.log('got get response', resp.statusCode, resp.body);
});
}
request(baseUrl + '/longpost', {
method: 'OPTIONS',
agent: agent
}, function(err, resp) {
if (err) {
throw err;
}
console.log('got options response', resp.statusCode);
console.log('sending post request')
request.post(baseUrl + '/longpost', {
agent: agent,
json: true,
body: {id: 1},
headers: [
{ name: 'Connection', value: 'keep-alive' }
]
}, function(err, resp) {
if (err) {
throw err;
}
console.log('got post response', resp.statusCode, resp.body);
});
});