Check that we can actually read from network and not just connect

When using Cloudflare, as we do for www.wxwidgets.org, the connection
succeeds as long as Cloudflare itself works, but reading later fails if
the real server behind Cloudflare proxy does not, so check if we can
read something from it.
This commit is contained in:
Vadim Zeitlin 2022-04-23 16:17:40 +01:00
parent 860dd39fab
commit 239bbd6b82

View file

@ -442,9 +442,13 @@ extern bool IsNetworkAvailable()
return false;
}
const char* const
HTTP_GET = "GET / HTTP /1.1\r\nHost: www.wxwidgets.org\r\n\r\n";
wxSocketClient sock;
sock.SetTimeout(10); // 10 secs
bool online = sock.Connect(addr);
bool online = sock.Connect(addr) &&
(sock.Write(HTTP_GET, strlen(HTTP_GET)), sock.WaitForRead(1));
wxSocketBase::Shutdown();