Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Request and StreamedRequest #1084

Open
glanium opened this issue Dec 18, 2023 · 0 comments
Open

About Request and StreamedRequest #1084

glanium opened this issue Dec 18, 2023 · 0 comments
Assignees
Labels
package:cronet_http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@glanium
Copy link

glanium commented Dec 18, 2023

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.

@glanium glanium added package:cronet_http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:cronet_http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants