You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add documentation describing how to use the Flutter engine HTTP blocking mechanism. #95341
Is there any way to do this without using Zone.fork? We are using runZonedGuarded in our app, but we wanted to use PlatformDispatcher.instance.onError instead as of Flutter 3.3. However, we can't do it because we need the zoneValues: {#flutter.io.allow_http: false}, from runZonedGuarded.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
/// Loopback connections are always allowed./// Zone override with 'flutter.io.allow_http' takes first priority./// If zone override is not provided, engine setting is checked.@pragma('vm:entry-point')
voidFunction(Uri) _getHttpConnectionHookClosure(bool mayInsecurelyConnectToAllDomains) {
return (Uri uri) {
finalObject? zoneOverride =Zone.current[#flutter.io.allow_http];
if (zoneOverride ==true) {
return;
}
if (zoneOverride ==false&& uri.isScheme('http')) {
// Going to _isLoopback check before throwing
} elseif (mayInsecurelyConnectToAllDomains || uri.isScheme('https')) {
// In absence of zone override, if engine setting allows the connection// or if connection is to `https`, allow the connection.return;
}
// Loopback connections are always allowed// Check at last resort to avoid debug annoyance of try/on ArgumentErrorif (_isLoopback(uri.host)) {
return;
}
throwUnsupportedError(
'Non-https connection "$uri" is not supported by the platform. ''Refer to https://flutter.dev/docs/release/breaking-changes/network-policy-ios-android.');
};
}
changed the title [-]Add option to block HTTP traffic [/-][+]Add documentation describing how to use the Flutter engine HTTP blocking mechanism.[/+]on Nov 13, 2023
Activity
aam commentedon Dec 20, 2021
See #69685 for origins of this flag, outlines of a plan to put it to use.
mateusfccp commentedon Oct 27, 2022
Is there any way to do this without using
Zone.fork? We are usingrunZonedGuardedin our app, but we wanted to usePlatformDispatcher.instance.onErrorinstead as of Flutter 3.3. However, we can't do it because we need thezoneValues: {#flutter.io.allow_http: false},fromrunZonedGuarded.huycozy commentedon Oct 4, 2023
From the primary triage perspective: I'm not sure which team would be suited to take this issue other than
engineteam.Hixie commentedon Oct 10, 2023
This is a Dart issue. If this is something that is still of interest, I recommend filing it at: https://github.com/dart-lang/sdk/issues/new/choose
In the meantime I'm going to close this.
github-actions commentedon Oct 24, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.brianquinlan commentedon Nov 7, 2023
A Dart issue was filed at dart-lang/sdk#53929 but it isn't obvious to me that this is a Dart issue.
A quick explanation of how the current mechanism works (copied from dart-lang/sdk#53929 (comment)):
HttpClientcalls_httpConnectionHookwhen connecting to a URL:Flutter Engine defines the close hook:
And Flutter Engine installs
_getHttpConnectionHookClosurehere:If I understand the request, it is to:
_getHttpConnectionHookClosureBoth of those would belong as part of Flutter.
[-]Add option to block HTTP traffic [/-][+]Add documentation describing how to use the Flutter engine HTTP blocking mechanism.[/+]