polling-xhr: always close body

This commit is contained in:
nkzawa
2017-07-11 21:26:22 +09:00
parent 75da2ea0b7
commit f3d92f9aac

View File

@@ -20,6 +20,7 @@ import okhttp3.MediaType;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.ResponseBody;
public class PollingXHR extends Polling { public class PollingXHR extends Polling {
@@ -196,10 +197,14 @@ public class PollingXHR extends Polling {
self.response = response; self.response = response;
self.onResponseHeaders(response.headers().toMultimap()); self.onResponseHeaders(response.headers().toMultimap());
if (response.isSuccessful()) { try {
self.onLoad(); if (response.isSuccessful()) {
} else { self.onLoad();
self.onError(new IOException(Integer.toString(response.code()))); } else {
self.onError(new IOException(Integer.toString(response.code())));
}
} finally {
response.close();
} }
} }
}); });