selfHttpTest method

Future<bool> selfHttpTest(
  1. HttpDcvData data, {
  2. int maxAttempts = 15,
})

A test whether the HTTP token is placed or not. Uses a simple HTTP GET request to check for the corresponding file on the server.

Implementation

Future<bool> selfHttpTest(HttpDcvData data, {int maxAttempts = 15}) async {
  for (var i = 0; i < maxAttempts; i++) {
    try {
      var response = await Dio().get(data.fileName);
      if (response.data is String) {
        if (response.data(String) == data.fileContent) {
          return true;
        }
      }
    } on DioException {
      // Do nothing
    }
    await Future.delayed(Duration(seconds: 4));
  }
  return false;
}