polling-xhr: always close body
This commit is contained in:
@@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user