toStreamedRequest function

Future<BaseRequest> toStreamedRequest (
  1. Stream<List<int>> bodyStream,
  2. String method,
  3. Uri uri,
  4. Map<String, String> headers
)

Implementation

Future<http.BaseRequest> toStreamedRequest(
  Stream<List<int>> bodyStream,
  String method,
  Uri uri,
  Map<String, String> headers,
) async {
  final req = http.StreamedRequest(method, uri);
  req.headers.addAll(headers);

  bodyStream.listen(req.sink.add,
      onDone: req.sink.close, onError: req.sink.addError);

  return req;
}