现在这种情况发生的频率降低了,但有时我们需要适应 HTTP 请求超时。该服务可能会出现故障、流量过大、编码不当或任何其他问题。
每当我需要模拟一个长的 HTTP 请求时,我都会使用一些 PHP 来实现它:
<?php // Don't resolve this request for 5 seconds sleep(5); // A generic response echo 'This is the response!'; // ... or hit a URL to make the case more realistic echo file_get_contents('https://website.tld/endpoint'); ?>
创建该脚本后,我让 PHP 启动一个服务器,这样我就可以在本地发出请求:
php -S localhost:8000
现在我可以点击 http://localhost:8000
并获得我想要的长请求!
您可以通过多种方式完成这些长表单请求,但这一直是我的最爱!