From 239bbd6b82057ae768a9111f07d0195a029d4301 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 23 Apr 2022 16:17:40 +0100 Subject: [PATCH] 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. --- tests/test.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test.cpp b/tests/test.cpp index e2b532e1a1..944f5923c5 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -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();