-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Draft PR for introducing a way to ban http #40549
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
Conversation
sdk/lib/_http/http_impl.dart
Outdated
@@ -2285,6 +2288,11 @@ class _HttpClient implements HttpClient { | |||
} | |||
|
|||
bool isSecure = (uri.scheme == "https"); | |||
bool isMobileClient = Platform.isAndroid || Platform.isIOS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove the restriction that the flag only works on mobile platforms, then I suspect it will be easier to write tests. A regular Dart program could just install an HttpOverrides in a zone with the flag flipped, and check that the right exception is thrown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two reasons for including a mobile client distinction:
- We intend to flip the default in google3 but only for mobile. The default should be
allow
for non-mobile applications even in google3. Perhaps, this can be solved by having defaults per Platform. - It reflects the principle of the change more accurately. On iOS and Android, we should not be asking the apps to install an Override to get this behavior. Both OSes ban cleartext HTTP by default for their native apps.
I introduced platform specific defaults to capture both points and removed the isMobileClient
check.
@@ -2151,6 +2152,13 @@ class _HttpClient implements HttpClient { | |||
|
|||
_HttpClient(this._context); | |||
|
|||
static bool get _isHttpAllowedByDefault { | |||
if (Platform.isIOS) return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe opposite value, i.e. false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a breaking change upstream.
I would be happy to do it but @mit-mit needs to agree.
This requires a rewrite. Closing. |
See proposal: #40548
Tests and documentation is missing as it is a POC.