From ff58a86b7fc3d4970bf9bf5b6926a411e22f5caa Mon Sep 17 00:00:00 2001 From: skilion Date: Sun, 25 Dec 2016 22:28:00 +0100 Subject: [PATCH] use libcurl to check connection --- src/util.d | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/util.d b/src/util.d index 6db7b0b7..b9515905 100644 --- a/src/util.d +++ b/src/util.d @@ -1,6 +1,7 @@ import std.conv; import std.digest.crc; import std.file; +import std.net.curl; import std.path; import std.regex; import std.socket; @@ -81,13 +82,9 @@ Regex!char wild2regex(const(char)[] pattern) // return true if the network connection is available bool testNetwork() { - try { - auto addr = new InternetAddress("login.live.com", 443); - auto socket = new TcpSocket(addr); - return socket.isAlive(); - } catch (SocketException) { - return false; - } + HTTP http = HTTP("https://login.live.com"); + http.method = HTTP.Method.head; + return http.perform(ThrowOnError.no) == 0; } // call globMatch for each string in pattern separated by '|'