[webview_flutter_android] Add headers to NavigationRequest to tell if it isDownloadRequest from onDownloadStart#11501
[webview_flutter_android] Add headers to NavigationRequest to tell if it isDownloadRequest from onDownloadStart#11501wuzhengu wants to merge 2 commits intoflutter:mainfrom
Conversation
… it isDownloadRequest from onDownloadStart
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the webview_flutter_android and webview_flutter_platform_interface packages to include request headers in NavigationRequest and introduces an isDownloadRequest getter to identify attachment downloads. The Android implementation is updated to populate these headers during download events. Feedback suggests making the 'attachment' string comparison case-insensitive to comply with RFC 6266 and adjusting Dart formatting.
| if(!contentDisposition.startsWith('attachment')) { | ||
| contentDisposition = 'attachment; $contentDisposition'.trim(); | ||
| } |
There was a problem hiding this comment.
The check for the attachment prefix should be case-insensitive, as HTTP header values are case-insensitive per RFC 6266. Also, there should be a space after the if keyword to follow standard Dart styling.
| if(!contentDisposition.startsWith('attachment')) { | |
| contentDisposition = 'attachment; $contentDisposition'.trim(); | |
| } | |
| if (!contentDisposition.toLowerCase().startsWith('attachment')) { | |
| contentDisposition = 'attachment; $contentDisposition'.trim(); | |
| } |
| final Map<String, String>? headers; | ||
|
|
||
| /// Indicates whether the request was made to download an attachment. | ||
| bool get isDownloadRequest => headers?['content-disposition']?.startsWith('attachment') ?? false; |
There was a problem hiding this comment.
The isDownloadRequest getter should perform a case-insensitive check for the attachment disposition type to comply with RFC 6266.
| bool get isDownloadRequest => headers?['content-disposition']?.startsWith('attachment') ?? false; | |
| bool get isDownloadRequest => headers?['content-disposition']?.toLowerCase().startsWith('attachment') ?? false; |
Add
headersandisDownloadRequesttoNavigationRequest,so we can easily tell if it was made to download an attachment fromonDownloadStart.List which issues are fixed by this PR. You must list at least one issue.
132738
Pre-Review Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2