onCall method

  1. @override
FutureOr<Message> onCall(
  1. Request request
)
override

Implementation

@override
FutureOr<Message> onCall(Request request) async {
  var base = (request as HttpStyleRequest).baseRequest;

  if (base.headers["if-none-match"] != null &&
      base.headers["if-none-match"] == tag) {
    base.response.statusCode = 304;
    base.response.contentLength = 0;
    base.response.close();
    return NoResponseRequired(request: request);
  }

  if (data == null) {
    await dataLoader;
  }

  base.response.contentLength = data!.length;
  base.response.headers
    ..add(HttpHeaders.contentTypeHeader, ContentType.binary.mimeType)
    ..add(HttpHeaders.cacheControlHeader, "must-revalidate")
    ..add(HttpHeaders.etagHeader, tag!);
  base.response.add(data!);
  base.response.close();
  return NoResponseRequired(request: request);
}