Use uv::async in HTTPAndroidRequest to ensure the correct thread deletes request object

Fixes #2058
This commit is contained in:
Leith Bade
2015-08-14 13:54:32 +10:00
parent b312820be8
commit 2f31687844
2 changed files with 47 additions and 69 deletions

View File

@@ -84,8 +84,15 @@ class HTTPContext {
@Override
public void onResponse(Response response) throws IOException {
byte[] body = response.body().bytes();
response.body().close();
byte[] body;
try {
body = response.body().bytes();
} catch (IOException e) {
onFailure(mRequest, e);
return;
} finally {
response.body().close();
}
nativeOnResponse(mNativePtr, response.code(), response.message(), response.header("ETag"), response.header("Last-Modified"), response.header("Cache-Control"), response.header("Expires"), body);
}