Created
August 31, 2017 17:29
-
-
Save roshanpal/cb84f45f5f5caf123a6946539dc8ad31 to your computer and use it in GitHub Desktop.
Node.js stress testing script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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