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

Add header for http.head in LocalOrNetworkImageProvider #2

Closed
Aoi-hosizora opened this issue Nov 27, 2020 · 1 comment
Closed

Add header for http.head in LocalOrNetworkImageProvider #2

Aoi-hosizora opened this issue Nov 27, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@Aoi-hosizora
Copy link
Owner

The http.head header should contain the headers parameter.

      int totalSize;
      http.head(url, headers: {
        'Accept': '*/*',
        'Accept-Encoding': '',
      }).then((data) {
        totalSize = int.tryParse(data.headers['content-length']);
      });
@Aoi-hosizora Aoi-hosizora added the bug Something isn't working label Nov 27, 2020
@Aoi-hosizora
Copy link
Owner Author

Aoi-hosizora commented Nov 28, 2020

Done

var h = (headers ?? {})..['Accept-Encoding'] = '';
int totalSize;
http.head(url, headers: {
  'Accept': '*/*',
  ...h,
}).then((data) {
  totalSize = int.tryParse(data.headers['content-length']);
}).catchError((_) {});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant