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
318ff7a0
Unverified
Commit
318ff7a0
authored
Mar 30, 2021
by
Dan Field
Committed by
GitHub
Mar 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drain socket before throwing (#79289)
parent
5151ea48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
_network_image_io.dart
packages/flutter/lib/src/painting/_network_image_io.dart
+1
-0
image_provider_network_image_test.dart
...tter/test/painting/image_provider_network_image_test.dart
+10
-1
No files found.
packages/flutter/lib/src/painting/_network_image_io.dart
View file @
318ff7a0
...
@@ -96,6 +96,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
...
@@ -96,6 +96,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
// The network may be only temporarily unavailable, or the file will be
// The network may be only temporarily unavailable, or the file will be
// added on the server later. Avoid having future calls to resolve
// added on the server later. Avoid having future calls to resolve
// fail to check the network again.
// fail to check the network again.
await
response
.
drain
<
List
<
int
>>();
throw
image_provider
.
NetworkImageLoadException
(
statusCode:
response
.
statusCode
,
uri:
resolved
);
throw
image_provider
.
NetworkImageLoadException
(
statusCode:
response
.
statusCode
,
uri:
resolved
);
}
}
...
...
packages/flutter/test/painting/image_provider_network_image_test.dart
View file @
318ff7a0
...
@@ -35,7 +35,7 @@ void main() {
...
@@ -35,7 +35,7 @@ void main() {
PaintingBinding
.
instance
!.
imageCache
!.
clearLiveImages
();
PaintingBinding
.
instance
!.
imageCache
!.
clearLiveImages
();
});
});
test
(
'Expect thrown exception with statusCode - evicts from cache'
,
()
async
{
test
(
'Expect thrown exception with statusCode - evicts from cache
and drains
'
,
()
async
{
final
int
errorStatusCode
=
HttpStatus
.
notFound
;
final
int
errorStatusCode
=
HttpStatus
.
notFound
;
const
String
requestUrl
=
'foo-url'
;
const
String
requestUrl
=
'foo-url'
;
...
@@ -68,6 +68,7 @@ void main() {
...
@@ -68,6 +68,7 @@ void main() {
.
having
((
NetworkImageLoadException
e
)
=>
e
.
statusCode
,
'statusCode'
,
errorStatusCode
)
.
having
((
NetworkImageLoadException
e
)
=>
e
.
statusCode
,
'statusCode'
,
errorStatusCode
)
.
having
((
NetworkImageLoadException
e
)
=>
e
.
uri
,
'uri'
,
Uri
.
base
.
resolve
(
requestUrl
)),
.
having
((
NetworkImageLoadException
e
)
=>
e
.
uri
,
'uri'
,
Uri
.
base
.
resolve
(
requestUrl
)),
);
);
expect
(
httpClient
.
request
.
response
.
drained
,
true
);
},
skip:
isBrowser
);
// Browser implementation does not use HTTP client but an <img> tag.
},
skip:
isBrowser
);
// Browser implementation does not use HTTP client but an <img> tag.
test
(
'Uses the HttpClient provided by debugNetworkImageHttpClientProvider if set'
,
()
async
{
test
(
'Uses the HttpClient provided by debugNetworkImageHttpClientProvider if set'
,
()
async
{
...
@@ -234,6 +235,8 @@ class _FakeHttpClientRequest extends Fake implements HttpClientRequest {
...
@@ -234,6 +235,8 @@ class _FakeHttpClientRequest extends Fake implements HttpClientRequest {
}
}
class
_FakeHttpClientResponse
extends
Fake
implements
HttpClientResponse
{
class
_FakeHttpClientResponse
extends
Fake
implements
HttpClientResponse
{
bool
drained
=
false
;
@override
@override
int
statusCode
=
HttpStatus
.
ok
;
int
statusCode
=
HttpStatus
.
ok
;
...
@@ -254,6 +257,12 @@ class _FakeHttpClientResponse extends Fake implements HttpClientResponse {
...
@@ -254,6 +257,12 @@ class _FakeHttpClientResponse extends Fake implements HttpClientResponse {
cancelOnError:
cancelOnError
,
cancelOnError:
cancelOnError
,
);
);
}
}
@override
Future
<
E
>
drain
<
E
>([
E
?
futureValue
])
async
{
drained
=
true
;
return
futureValue
??
<
int
>[]
as
E
;
}
}
}
class
FakeCodec
implements
Codec
{
class
FakeCodec
implements
Codec
{
...
...
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