http
http copied to clipboard
About Request and StreamedRequest
There are Request and StreamedRequest in http package.
What does streaming mean in the context of this http package? I think streaming means something like transferring bytes in chunks in the context of http. However, cronet_http does not support sending request bodies in chunks. So i think when passing in StreamedRequst, it should raise Exception.
@override
Future<StreamedResponse> send(BaseRequest request) async {
if (_isClosed) {
throw ClientException(
'HTTP request failed. Client is already closed.', request.url);
}
if (request is StreamedRequest) {
throw Exception('not support'); // <-- here
}
_engine ??= CronetEngine.build();
final stream = request.finalize();
final body = await stream.toBytes(); // <--- this is not streaming. all data in memory.
final responseCompleter = Completer<StreamedResponse>();
final engine = _engine!._engine;
By raising excepption, developer will know this library does not support chunk transfer.