Response constructor

Response(
  1. int statusCode,
  2. String reasonPhrase,
  3. Headers headers,
  4. dynamic body, {
  5. List<RedirectInfo>? redirects,
  6. String? requestAddress,
  7. String? responseAddress,
})

Creates a HTTP Response object.

Implementation

Response(
  this.statusCode,
  this.reasonPhrase,
  this.headers,
  dynamic body, {
  this.redirects,
  this.requestAddress,
  this.responseAddress,
}) {
  if (body is String) {
    _bodyText = body;
  } else if (body is List<int>) {
    _bodyBytes = body;
  } else if (body is Stream<List<int>>) {
    _doneCompleter = Completer();
    _bodyStream =
        body.transform(StreamTransformer<List<int>, List<int>>.fromHandlers(
      handleDone: (sink) {
        sink.close();
        _doneCompleter.complete();
      },
    ));
  } else {
    _body = body;
  }
}