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

Http client stream listen only called when the file is downloading #502

Closed
kjawadDeveloper opened this issue Dec 2, 2020 · 2 comments
Closed
Labels
type-question A question about expected behavior or functionality

Comments

@kjawadDeveloper
Copy link

I want to listen to the progress during the image download. It works well in android and ios but in the web I only get this listen to callback when the image is downloaded.

    var _response = await Client().send(Request("GET",  
    Uri.parse("https://upload.wikimedia.org/wikipedia/commons/f/ff/Pizigani_1367_Chart_10MB.jpg")));

    _total = _response.contentLength;


      _response.stream.listen((value) {
            print("received: ${value.length}");
            _bytes.addAll(value);
            _received += value.length;

        setState(() {

            });
      }).onDone(() {
          setState(() {
            // _image = Uint8List.fromList(_bytes);
          });
      });```
@ditman
Copy link
Member

ditman commented Apr 8, 2021

It seems the browser_client.dart is only listening to the onLoad event of a request, instead of its progress events:

This is probably why when send is used in the web, the response goes straight from 0 to 100% in only one progress event.

@natebosch natebosch added the type-question A question about expected behavior or functionality label Jul 15, 2021
@natebosch
Copy link
Member

The browser client does not support streaming because it uses XmlHttpRequest so no response object becomes available until the entire response is read. No plans in the short term, but we might investigate using fetch to support streaming. #595

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-question A question about expected behavior or functionality
Projects
None yet
Development

No branches or pull requests

3 participants