ServerResponse.bytes constructor
ServerResponse.bytes(})
Creates a response from buffered bytes.
Implementation
factory ServerResponse.bytes(
List<int> bytes, {
int status = 200,
String? contentType,
Headers? headers,
}) {
final resolved = headers?.copy() ?? Headers();
if (contentType != null) resolved.set('content-type', contentType);
resolved.set('content-length', '${bytes.length}');
return ServerResponse(
status: status,
headers: resolved,
body: Stream<List<int>>.value(bytes),
);
}