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
a772d4d3
Unverified
Commit
a772d4d3
authored
Jun 17, 2019
by
Jonah Williams
Committed by
GitHub
Jun 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retry on HttpException (#34526)
parent
ac2f85bb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
io.dart
packages/flutter_tools/lib/src/base/io.dart
+1
-0
net.dart
packages/flutter_tools/lib/src/base/net.dart
+3
-0
net_test.dart
packages/flutter_tools/test/base/net_test.dart
+26
-0
No files found.
packages/flutter_tools/lib/src/base/io.dart
View file @
a772d4d3
...
...
@@ -48,6 +48,7 @@ export 'dart:io'
HttpClientRequest
,
HttpClientResponse
,
HttpClientResponseCompressionState
,
HttpException
,
HttpHeaders
,
HttpRequest
,
HttpServer
,
...
...
packages/flutter_tools/lib/src/base/net.dart
View file @
a772d4d3
...
...
@@ -64,6 +64,9 @@ Future<List<int>> _attempt(Uri url, { bool onlyHeaders = false }) async {
}
on
SocketException
catch
(
error
)
{
printTrace
(
'Download error:
$error
'
);
return
null
;
}
on
HttpException
catch
(
error
)
{
printTrace
(
'Download error:
$error
'
);
return
null
;
}
final
HttpClientResponse
response
=
await
request
.
close
();
// If we're making a HEAD request, we're only checking to see if the URL is
...
...
packages/flutter_tools/test/base/net_test.dart
View file @
a772d4d3
...
...
@@ -105,6 +105,32 @@ void main() {
),
});
testUsingContext
(
'retry from HttpException'
,
()
async
{
String
error
;
FakeAsync
().
run
((
FakeAsync
time
)
{
fetchUrl
(
Uri
.
parse
(
'http://example.invalid/'
)).
then
((
List
<
int
>
value
)
{
error
=
'test completed unexpectedly'
;
},
onError:
(
dynamic
exception
)
{
error
=
'test failed unexpectedly:
$exception
'
;
});
expect
(
testLogger
.
statusText
,
''
);
time
.
elapse
(
const
Duration
(
milliseconds:
10000
));
expect
(
testLogger
.
statusText
,
'Download failed -- attempting retry 1 in 1 second...
\n
'
'Download failed -- attempting retry 2 in 2 seconds...
\n
'
'Download failed -- attempting retry 3 in 4 seconds...
\n
'
'Download failed -- attempting retry 4 in 8 seconds...
\n
'
,
);
});
expect
(
testLogger
.
errorText
,
isEmpty
);
expect
(
error
,
isNull
);
expect
(
testLogger
.
traceText
,
contains
(
'Download error: HttpException'
));
},
overrides:
<
Type
,
Generator
>{
HttpClientFactory:
()
=>
()
=>
MockHttpClientThrowing
(
const
io
.
HttpException
(
'test exception handling'
),
),
});
testUsingContext
(
'max attempts'
,
()
async
{
String
error
;
List
<
int
>
actualResult
;
...
...
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