head method

  1. @override
Future<Response> head(
  1. Uri url, {
  2. Map<String, String>? headers,
})

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
  }
}