Skip to content

Commit

Permalink
Merge pull request flutter#1693 from jimbeveridge/close
Browse files Browse the repository at this point in the history
Close the UrlLoaderProxy on error.
  • Loading branch information
jimbeveridge committed Oct 20, 2015
2 parents bbfc3e8 + 924b9a7 commit 9826b5b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sky/packages/sky/lib/src/services/fetch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,25 @@ class Response {
}

Future<UrlResponse> fetch(UrlRequest request) async {
UrlLoaderProxy loader = new UrlLoaderProxy.unbound();
try {
UrlLoaderProxy loader = new UrlLoaderProxy.unbound();
_networkService.ptr.createUrlLoader(loader);
UrlResponse response = (await loader.ptr.start(request)).response;
loader.close();
return response;
} catch (e) {
print("NetworkService unavailable $e");
return new UrlResponse()..statusCode = 500;
} finally {
loader.close();
}
}

Future<UrlResponse> fetchUrl(String relativeUrl) async {
Future<UrlResponse> fetchUrl(String relativeUrl) {
String url = Uri.base.resolve(relativeUrl).toString();
UrlRequest request = new UrlRequest()
..url = url
..autoFollowRedirects = true;
return await fetch(request);
return fetch(request);
}

Future<Response> fetchBody(String relativeUrl) async {
Expand Down

0 comments on commit 9826b5b

Please sign in to comment.