ServerResponse.notModified constructor

ServerResponse.notModified({
  1. String? etag,
  2. DateTime? lastModified,
  3. String? cacheControl,
  4. Map<String, String>? headers,
})

Creates a 304 Not Modified conditional response.

Implementation

factory ServerResponse.notModified({
  String? etag,
  DateTime? lastModified,
  String? cacheControl,
  Map<String, String>? headers,
}) {
  return ServerResponse(
    statusCode: 304,
    headers: {
      if (etag != null) 'ETag': etag,
      if (lastModified != null)
        'Last-Modified': lastModified.toUtc().toIso8601String(),
      if (cacheControl != null) 'Cache-Control': cacheControl,
      if (headers != null) ...headers,
    },
    body: '',
  );
}