MockStreamedResponse constructor
MockStreamedResponse(})
Implementation
MockStreamedResponse(int status,
{Stream<List<int>>? byteStream,
Encoding? encoding,
Map<String, String>? headers,
String? statusText}) {
// Ensure the headers are case insensitive.
headers = CaseInsensitiveMap<String>.from(headers ?? {});
// If an encoding was given, update the content-type charset parameter.
if (encoding != null) {
MediaType contentType = http_utils.parseContentTypeFromHeaders(headers);
contentType = contentType.change(parameters: {'charset': encoding.name});
headers['content-type'] = contentType.toString();
}
// Use a default status text based on the status code if one is not given.
statusText ??= _mapStatusToText(status);
byteStream ??= Stream.fromIterable([]);
// Construct the body according to the data type.
_response = StreamedResponse.fromByteStream(
status, statusText, headers, byteStream);
}