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

Chunked stream reading doesn't work correct ( Dio().get<ResponseBody> Options(responseType: ResponseType.stream)) #1621

Closed
Pepslee opened this issue Jan 22, 2023 · 2 comments

Comments

@Pepslee
Copy link

Pepslee commented Jan 22, 2023

From Dio documentation:

Response<ResponseBody> rs;
rs = await Dio().get<ResponseBody>(url,
  options: Options(responseType: ResponseType.stream),  // set responseType to `stream`
);
print(rs.data.stream);


rs.data?.stream
        .listen((event) {
      log(event);
    });

Server sends chunked data (10 chunks during 10 seconds, so 1 chunk every second), but this call

 await Dio().get<ResponseBody>(url,
  options: Options(responseType: ResponseType.stream),  // set responseType to `stream`
);

awaits just after stream is done, so I receive all chunks in one moment. This await waits 10 second and just then stream.listen will be run and I will receive all 10 chunks in one moment.

But I want to receive chunks right at the moment when server is sending them.

@Pepslee Pepslee changed the title Chunked stream doesn't work correct Chunked stream reading doesn't work correct ( Dio().get<ResponseBody> Options(responseType: ResponseType.stream)) Jan 22, 2023
@clotodex
Copy link

Was there any solution or documentation? I am running in the same issue

@leferrad
Copy link

Same issue here! Could anyone find a solution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants