head method

  1. @override
Future<Either<Failure, Response>> head({
  1. required String endpoint,
  2. Map<String, dynamic>? params,
  3. Duration? receiveTimeout,
  4. Duration? sendTimeout,
  5. Map<String, String>? headers,
  6. CancelToken? cancelToken,
  7. String? tag,
  8. bool? retryable,
  9. Map<String, dynamic>? extra,
  10. bool showLoader = true,
  11. bool dedupe = true,
})
override

Sends a HEAD request to endpoint.

Identical to get except that the server returns headers only and no body — use it to check whether a resource exists, read its Content-Length before committing to a download, or test a Last-Modified without paying for the payload.

final result = await _api.head(endpoint: '/files/report.pdf');
final size = result.fold(
  (_) => null,
  (response) => response.headers.value('content-length'),
);

Idempotent, so transient failures are retried like a get. Takes no responseType: there is no body for one to apply to.

Implementation

@override
Future<Either<Failure, Response>> head({
  required String endpoint,
  Map<String, dynamic>? params,
  Duration? receiveTimeout,
  Duration? sendTimeout,
  Map<String, String>? headers,
  CancelToken? cancelToken,
  String? tag,
  bool? retryable,
  Map<String, dynamic>? extra,
  bool showLoader = true,
  bool dedupe = true,
}) {
  return _respond(
    HttpMethod.head,
    endpoint,
    params: params,
    headers: headers,
    tag: tag,
    retryable: retryable,
    extra: extra,
    cancelToken: cancelToken,
    evaluate: false,
  );
}