-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
38 lines (33 loc) · 815 Bytes
/
test.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
const CFG_URL = "baidu.com";
var http = require('http');
var json_data = JSON.stringify({
source: ["fs","ss"],
trans_type: "en2zh",
page_id: 144200,
replaced: true,
cached: true
})
var makeRequest = function(message) {
var options = {
host: CFG_URL,
port: 80,
path: '/',
method: 'POST',
timeout: 1500,
headers: {
'Content-Type': 'application/text',
'Content-Length': message.length
}
}
var request = http.request(options, function(response) {
response.on('data', function(data) {
console.log(data);
});
});
process.on('uncaughtException', function (err) {
console.log(err);
});
request.write(message);
request.end();
}
makeRequest(json_data);