/
githubmirror
/
pm2
Обзор
Документация
Войти
/
githubmirror
/
pm2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/fixtures/interface/http_transaction.js
49 строк
1 KB
Unitech
v7 refactor
08 фев 2026, 17:04
08 фев 2026, 17:04
04fad96
Код
Авторство
О чём код?
var axm = require('../../../modules/pm2-io-bpm'); axm.init({ http: true }) var http = require('http'); http.createServer(function(req, res) { res.writeHead(200); setTimeout(function() { res.end('transaction'); }, 1000); }).listen(9010); setInterval(function() { request(['/user', '/bla', '/user/lol/delete', '/POST/POST'][Math.floor((Math.random() * 4))]); }, 100); function makeid() { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for( var i=0; i < 5; i++ ) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; } function request(path) { var options = { hostname: '127.0.0.1' ,port: 9010 ,path: path || '/users' ,method: 'GET' ,headers: { 'Content-Type': 'application/json' } }; var req = http.request(options, function(res) { res.setEncoding('utf8'); res.on('data', function (data) { console.log(data); // I can't parse it because, it's a string. why? }); }); req.on('error', function(e) { console.log('problem with request: ' + e.message); }); req.end(); }