Skip to content

Instantly share code, notes, and snippets.

@roshanpal
Created August 31, 2017 17:29
Show Gist options
  • Save roshanpal/cb84f45f5f5caf123a6946539dc8ad31 to your computer and use it in GitHub Desktop.
Save roshanpal/cb84f45f5f5caf123a6946539dc8ad31 to your computer and use it in GitHub Desktop.
Node.js stress testing script
var request = require('request');
// Set the headers
var headers = {
'User-Agent': 'Super Agent/0.0.1',
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': ''
}
// Configure the request
var options = {
url: '',
method: 'POST',
headers: headers,
form: {}
}
// Start the request
for (i = 0; i < 100; i++) {
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
// Print out the response body
console.log(body);
}
});
console.log(i + 'th request sent');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment