head method
Sends an HTTP HEAD request with the given headers to the given URL.
For more fine-grained control over the request, use send instead.
Implementation
@override
Future<http.Response> head(Uri url, {Map<String, String>? headers}) async {
try {
// Log head request details
String headersLog = (headers != null)
? '\nš Headers: ${jsonEncode(headers)}'
: '\nš Headers: None';
_logger.i('š š Head Request š š\nš URL: $url$headersLog');
// Perform the head request
final response = await _inner.head(url, headers: headers);
// Log head response details
String responseData =
'\nš URL: $url\nš Status Code: ${response.statusCode}\nš Headers: ${jsonEncode(response.headers)}';
_logger.i('ā
š Head Response š ā
$responseData');
return response;
} catch (error) {
// Log head error
_logger.e('ā ā Head ERROR ā ā\nā Error Message: $error');
rethrow; // Rethrow the error after logging
}
}