checkRemoteAssociationFiles method
GET both association files from the live domain and check status, JSON-parseability, and (for the AASA) content-type.
Never called unless --remote is passed: a doctor that hangs on DNS is
a doctor nobody runs.
Implementation
Future<RemoteCheckResult> checkRemoteAssociationFiles() async {
final domain = _loadConfig()['domain'] as String?;
if (domain == null || domain.isEmpty) {
return const RemoteCheckResult(
['--remote requires deeplink.domain to be configured'],
[],
);
}
final issues = <String>[];
final warnings = <String>[];
for (final fileName in const [
'apple-app-site-association',
'assetlinks.json',
]) {
final uri = Uri.parse('https://$domain/.well-known/$fileName');
try {
final result = await fetchRemoteFile(uri);
if (result.statusCode != 200) {
issues.add(
'$uri responded ${result.statusCode}, expected 200 with no redirect');
continue;
}
try {
jsonDecode(result.body);
} on FormatException {
issues.add('$uri did not return a body that parses as JSON');
}
if (fileName == 'apple-app-site-association' &&
result.contentType != 'application/json') {
warnings.add(
'$uri served content-type "${result.contentType}", expected application/json',
);
}
} on Exception catch (e) {
issues.add('$uri could not be reached: $e');
}
}
return RemoteCheckResult(issues, warnings);
}