How can I simulate a down site?

I am writing some transition code to another resource, so if my desktop application cannot connect to its website, it may instead try to create a backup website.

However, I cannot figure out how to simulate a test if the site is down or not. If I try the wrong URL, for example "http: //www.mybadsite.badTLD", my ISP will send me to the default catch page.

At a time when the site is really unavailable, and you cannot connect to it, you will receive a message in the browser that says that it cannot connect. This is what I need to imitate.

thank

+5
source share
4 answers

Modify the hosts file to override the host you are trying to connect to. You can do 127.0.0.2 (or something unreachable).

You can also run a test with 0.0.0.0 -, which returns another error (Invalid IP). It may also be useful to check for this.

Your ISP will redirect the request for a DNS lookup failure, but all that is allowed with your short circuits on the host files.

+6
source
http://localhost

Assuming you don't have a server running locally ...

+2
source

, , , HTTP. httpstat.us

http 503 (Service Unavailable).

503 , -

, , .

http IETS

+2

, 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);

. . :

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

+1

All Articles