head method
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 showLoader = true,
- 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 showLoader = true,
bool dedupe = true,
}) {
return _respond(
HttpMethod.head,
endpoint,
params: params,
headers: headers,
tag: tag,
cancelToken: cancelToken,
evaluate: false,
);
}