don't run the test that requires proper NX_DOMAIN support if the internet connection doesn't support it

This commit is contained in:
Arvid Norberg 2010-08-28 20:32:58 +00:00
parent 18a3d545b0
commit 12b36ad9e0
1 changed files with 13 additions and 6 deletions

View File

@ -158,12 +158,19 @@ void run_suite(std::string const& protocol, proxy_settings const& ps, int port)
run_test(url_base + "test_file", 3216, 200, 1, error_code(), ps);
run_test(url_base + "test_file.gz", 3216, 200, 1, error_code(), ps);
run_test(url_base + "non-existing-file", -1, 404, 1, err(), ps);
// only run the tests to handle NX_DOMAIN if we have a proper internet
// connection that doesn't inject false DNS responses (like Comcast does)
hostent* h = gethostbyname("non-existent-domain.se");
if (h == 0 && h_errno == HOST_NOT_FOUND)
{
// if we're going through an http proxy, we won't get the same error as if the hostname
// resolution failed
if ((ps.type == proxy_settings::http || ps.type == proxy_settings::http_pw) && protocol != "https")
run_test(protocol + "://non-existent-domain.se/non-existing-file", -1, 502, 1, err(), ps);
else
run_test(protocol + "://non-existent-domain.se/non-existing-file", -1, -1, 0, err(), ps);
}
if (ps.type != proxy_settings::none)
stop_proxy(ps.port);