Skip to content

Conversation

@jonas-martinez
Copy link
Contributor

@jonas-martinez jonas-martinez commented Jul 6, 2021

This PR adds support for headers in the NetworkImage widget for Flutter Web. The documentation for the headers property mentions When running flutter on the web, headers are not used. which should not be the case or at least this property should be removed as it can be confusing.
Our specific use case was that we needed to pass an Authorization header using the Image.network component which was not possible using Flutter Web.

Fixes 57187

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 6, 2021
@google-cla google-cla bot added the cla: yes label Jul 6, 2021
@goderbauer goderbauer added the platform-web Web applications specifically label Jul 7, 2021
@goderbauer
Copy link
Member

@jonas-martinez Can you please add a test for this?

/cc @yjbanov @GaryQian Can one of you take a look at this?

@google-cla
Copy link

google-cla bot commented Jul 13, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Jul 13, 2021
@jonas-martinez
Copy link
Contributor Author

@googlebot I fixed it.

@google-cla
Copy link

google-cla bot commented Jul 13, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@jonas-martinez
Copy link
Contributor Author

@googlebot I fixed it.

@google-cla
Copy link

google-cla bot commented Jul 13, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@jonas-martinez
Copy link
Contributor Author

@googlebot I consent.

@google-cla
Copy link

google-cla bot commented Jul 13, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@jonas-martinez-lenra
Copy link

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Jul 13, 2021
@jonas-martinez jonas-martinez force-pushed the enhancement/flutter-web-support-image-network-headers branch from 28ea584 to f5aeaea Compare July 13, 2021 15:13
@goderbauer goderbauer requested review from GaryQian and yjbanov July 14, 2021 21:36
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #85954 at sha 2bcf390cf5c7a7925682df7bb8c4235619644e22

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Jul 20, 2021
@yjbanov
Copy link
Contributor

yjbanov commented Jul 21, 2021

This PR needs a test.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #85954 at sha fe9e942012dc7c838ebc66bcda0c1af2e4d3f8ba

@goderbauer
Copy link
Member

(PR triage): @jonas-martinez do you still have plans to come back to this PR to add some tests?

@jonas-martinez
Copy link
Contributor Author

jonas-martinez commented Aug 4, 2021

(PR triage): @jonas-martinez do you still have plans to come back to this PR to add some tests?

@goderbauer I recently tried to add some tests, I could not figure out a way to make them work properly. I will not be able to work on that for 2 weeks so during this time any idea or implementation about how to add good tests to this PR would be welcomed.

Sorry for the delay

@Piinks Piinks added the a: images Loading, displaying, rendering images label Aug 17, 2021
@yjbanov
Copy link
Contributor

yjbanov commented Aug 21, 2021

We'd probably need a test that's similar to the engine variant (the first interesting test there is probably "skiaInstantiateWebImageCodec loads an image from the network"). Since the test would be testing web-specific functionality, I would suggest to also use conditional imports in the test and import dart:html directly. I believe the conditional import will also allow the test to import _network_image_web.dart directly and mock out the network API.

When using conditional imports you need to provide both a web version and a mobile version. Since there's nothing to test for the mobile version, you can make it a noop, just an empty function that doesn't test anything (example).

Here's a rough sketch:

// network_image_web_test.dart
import '_network_image_web_io_test.dart' if (dart.library.html) '_network_image_web_test.dart';
void main() {
  runTests();
}

// _network_image_web_io_test.dart
void runTests() {
  // This is a web-specific test. Nothing to do for AOT engine.
}

// _network_image_web_test.dart
void runTests() {
  test('loads an image from the network', () {
    ...
  });
}

@jonas-martinez jonas-martinez force-pushed the enhancement/flutter-web-support-image-network-headers branch from 3af46e6 to fa3027c Compare December 30, 2021 09:52
@jonas-martinez
Copy link
Contributor Author

@jonas-martinez can you try doing a git rebase instead? It usually solves this kind of problem with customer_testing

Thank you @nt4f04uNd ! Problem solved

@CaseyHillers CaseyHillers removed their request for review January 3, 2022 15:57
@goderbauer
Copy link
Member

(triage) Looks like all this needs is a secondary review now. I've asked on discord if somebody is up for it.

@tstarasinic
Copy link

What is the state with this feature ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: images Loading, displaying, rendering images framework flutter/packages/flutter repository. See also f: labels. platform-web Web applications specifically will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Web] add HTTP headers support for NetworkImage