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,11 +197,15 @@ public class PollingXHR extends Polling {
self.response = response; self.response = response;
self.onResponseHeaders(response.headers().toMultimap()); self.onResponseHeaders(response.headers().toMultimap());
try {
if (response.isSuccessful()) { if (response.isSuccessful()) {
self.onLoad(); self.onLoad();
} else { } else {
self.onError(new IOException(Integer.toString(response.code()))); self.onError(new IOException(Integer.toString(response.code())));
} }
} finally {
response.close();
}
} }
}); });
} }