EDIT
主机文件重新定义您要连接到的主机。 您可以执行127.0.0.2(或其他任何无法达到的)。
您还可以使用0.0.0.0进行测试 - 返回不同的错误(无效的IP)。 测试也可能有一些好处。 您的ISP正在重定向DNS查找故障,但是您的主机文件所解决的任何内容。
如果您拥有运行PHP的服务器,则可以使用Header()函数将HTTP错误代码的标题发送回您的应用程序。
header("HTTP/1.0 404: Not Found", true, 404);
header("HTTP/1.0 403: Forbidden", true, 403);
或者
header("HTTP/1.0 500: Internal Server Error", true, 500);
我使用此Web服务如下:
curl -v http://httpstat.us/<http status code>
例如:
curl -v http://httpstat.us/503
> GET /503 HTTP/1.1
> Host: httpstat.us
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 503 Service Unavailable
...
.