Created
June 12, 2020 03:30
-
-
Save NimJay/b2ccb19360cc043c472b24c4e6008df2 to your computer and use it in GitHub Desktop.
This bit of JavaScript can be used to repeatedly make an HTTP request to an endpoint.
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
/** | |
* This script could be used to test whether an endpoint could handle an overload | |
* of HTTP requests. | |
*/ | |
{ | |
const URL = "https://example.com"; | |
const MILLISEC_WAIT_PER_REQUEST = 100; | |
function bombardWithHttpRequest() { | |
fetch(URL) | |
.then(function(response) { | |
return response.json(); | |
}); | |
return delay(MILLISEC_WAIT_PER_REQUEST) | |
.then(ddos); | |
} | |
function delay(ms) { | |
return new Promise((res, rej) => { | |
setTimeout(res, ms); | |
}); | |
} | |
// bombardWithHttpRequest(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment