Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0566971d
Unverified
Commit
0566971d
authored
Aug 15, 2019
by
Zachary Anderson
Committed by
GitHub
Aug 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Throw tool exit on malformed storage url override (#38637)
parent
7a138ca5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
+42
-2
net.dart
packages/flutter_tools/lib/src/base/net.dart
+14
-0
net_test.dart
packages/flutter_tools/test/general.shard/base/net_test.dart
+28
-2
No files found.
packages/flutter_tools/lib/src/base/net.dart
View file @
0566971d
...
@@ -8,6 +8,7 @@ import '../base/context.dart';
...
@@ -8,6 +8,7 @@ import '../base/context.dart';
import
'../globals.dart'
;
import
'../globals.dart'
;
import
'common.dart'
;
import
'common.dart'
;
import
'io.dart'
;
import
'io.dart'
;
import
'platform.dart'
;
const
int
kNetworkProblemExitCode
=
50
;
const
int
kNetworkProblemExitCode
=
50
;
...
@@ -53,6 +54,19 @@ Future<List<int>> _attempt(Uri url, { bool onlyHeaders = false }) async {
...
@@ -53,6 +54,19 @@ Future<List<int>> _attempt(Uri url, { bool onlyHeaders = false }) async {
}
else
{
}
else
{
request
=
await
httpClient
.
getUrl
(
url
);
request
=
await
httpClient
.
getUrl
(
url
);
}
}
}
on
ArgumentError
catch
(
error
)
{
final
String
overrideUrl
=
platform
.
environment
[
'FLUTTER_STORAGE_BASE_URL'
];
if
(
overrideUrl
!=
null
&&
url
.
toString
().
contains
(
overrideUrl
))
{
printError
(
error
.
toString
());
throwToolExit
(
'The value of FLUTTER_STORAGE_BASE_URL (
$overrideUrl
) could not be '
'parsed as a valid url. Please see https://flutter.dev/community/china '
'for an example of how to use it.
\n
'
'Full URL:
$url
'
,
exitCode:
kNetworkProblemExitCode
,);
}
printError
(
error
.
toString
());
rethrow
;
}
on
HandshakeException
catch
(
error
)
{
}
on
HandshakeException
catch
(
error
)
{
printTrace
(
error
.
toString
());
printTrace
(
error
.
toString
());
throwToolExit
(
throwToolExit
(
...
...
packages/flutter_tools/test/general.shard/base/net_test.dart
View file @
0566971d
...
@@ -7,6 +7,7 @@ import 'dart:typed_data';
...
@@ -7,6 +7,7 @@ import 'dart:typed_data';
import
'package:flutter_tools/src/base/io.dart'
as
io
;
import
'package:flutter_tools/src/base/io.dart'
as
io
;
import
'package:flutter_tools/src/base/net.dart'
;
import
'package:flutter_tools/src/base/net.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:quiver/testing/async.dart'
;
import
'package:quiver/testing/async.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
...
@@ -105,7 +106,32 @@ void main() {
...
@@ -105,7 +106,32 @@ void main() {
),
),
});
});
testUsingContext
(
'retry from HttpException'
,
()
async
{
testUsingContext
(
'check for bad override on ArgumentError'
,
()
async
{
String
error
;
FakeAsync
().
run
((
FakeAsync
time
)
{
fetchUrl
(
Uri
.
parse
(
'example.invalid/'
)).
then
((
List
<
int
>
value
)
{
error
=
'test completed unexpectedly'
;
},
onError:
(
dynamic
exception
)
{
error
=
'test failed:
$exception
'
;
});
expect
(
testLogger
.
statusText
,
''
);
time
.
elapse
(
const
Duration
(
milliseconds:
10000
));
expect
(
testLogger
.
statusText
,
''
);
});
expect
(
error
,
startsWith
(
'test failed'
));
expect
(
testLogger
.
errorText
,
contains
(
'Invalid argument'
));
expect
(
error
,
contains
(
'FLUTTER_STORAGE_BASE_URL'
));
},
overrides:
<
Type
,
Generator
>{
HttpClientFactory:
()
=>
()
=>
MockHttpClientThrowing
(
ArgumentError
(
'test exception handling'
),
),
Platform:
()
=>
FakePlatform
.
fromPlatform
(
const
LocalPlatform
())
..
environment
=
<
String
,
String
>{
'FLUTTER_STORAGE_BASE_URL'
:
'example.invalid'
},
});
testUsingContext
(
'retry from HttpException'
,
()
async
{
String
error
;
String
error
;
FakeAsync
().
run
((
FakeAsync
time
)
{
FakeAsync
().
run
((
FakeAsync
time
)
{
fetchUrl
(
Uri
.
parse
(
'http://example.invalid/'
)).
then
((
List
<
int
>
value
)
{
fetchUrl
(
Uri
.
parse
(
'http://example.invalid/'
)).
then
((
List
<
int
>
value
)
{
...
@@ -183,7 +209,7 @@ testUsingContext('retry from HttpException', () async {
...
@@ -183,7 +209,7 @@ testUsingContext('retry from HttpException', () async {
class
MockHttpClientThrowing
implements
io
.
HttpClient
{
class
MockHttpClientThrowing
implements
io
.
HttpClient
{
MockHttpClientThrowing
(
this
.
exception
);
MockHttpClientThrowing
(
this
.
exception
);
final
Exception
exception
;
final
Object
exception
;
@override
@override
Future
<
io
.
HttpClientRequest
>
getUrl
(
Uri
url
)
async
{
Future
<
io
.
HttpClientRequest
>
getUrl
(
Uri
url
)
async
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment