Created
August 12, 2016 13:09
-
-
Save adentify/9a53eec0c2d69a18c265f20943996a22 to your computer and use it in GitHub Desktop.
PHP Delay response, handy for testing code dealing with slow responding sites.
This file contains hidden or 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
| <?php | |
| header("Content-type: text/plain"); | |
| $payload = ""; | |
| // pass delay as param with length of 'd' in milliseconds | |
| if(isset($_GET['delay'])){ | |
| $delay = $_GET['delay']; | |
| if($delay > 30000){ | |
| $delay = 0; | |
| $payload .= "// max timeout exceeded, we've set this as 0ms\n"; | |
| } | |
| } else { | |
| $delay = 2000; | |
| } | |
| usleep($delay*1000); // usleep works in microseconds, we pass d as milliseconds | |
| if(isset($_GET['body'])){ | |
| $payload .= $_GET['body']; | |
| } else { | |
| $payload .= "var delaystatus = true;\n"; | |
| $payload .= "var delaytime = $delay; // milliseconds max = 30000"; | |
| } | |
| print $payload; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment