mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-15 20:26:53 +02:00
use libcurl to check connection
This commit is contained in:
parent
91c5ac6f31
commit
ff58a86b7f
11
src/util.d
11
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 '|'
|
||||
|
|
Loading…
Reference in a new issue