onResponse method
Called after the response is received
Implementation
@override
void onResponse(String method, String url, DohResponse response) {
if (!enabled) return;
// Calculate response time
final int startTime =
_requestTimestamps[url] ?? DateTime.now().millisecondsSinceEpoch;
final int responseTime = DateTime.now().millisecondsSinceEpoch - startTime;
// Clean up timestamp
_requestTimestamps.remove(url);
_printResponseHeader(method, url, response.statusCode, responseTime);
if (responseBody) {
final responseBlock = StringBuffer('╔ Body\n');
final data = response.data;
// ignore: unnecessary_type_check
if (data is Map) {
responseBlock.write(_formatPrettyMap(data));
} else if (data is Uint8List) {
responseBlock.write('${_indent()}[\n');
responseBlock.write(_formatUint8List(data as Uint8List));
responseBlock.write('${_indent()}]\n');
} else if (data is List) {
responseBlock.write('${_indent()}[\n');
responseBlock.write(_formatList(data as List));
responseBlock.write('${_indent()}]\n');
} else {
responseBlock.write(data.toString());
}
responseBlock.write('╚ ${_repeatChar('═', maxWidth)}');
logPrint(responseBlock.toString());
}
}