in src/main/java/com/microsoft/azure/spark/tools/http/HttpObservable.java [303:334]
public static Observable<HttpResponse> toStringOnlyOkResponse(
final CloseableHttpResponse closeableHttpResponse) {
return Observable.using(
// Resource factory
() -> closeableHttpResponse,
// Observable factory
streamResp -> {
try {
StatusLine status = streamResp.getStatusLine();
if (status.getStatusCode() >= 300) {
return Observable.error(classifyHttpError(streamResp));
}
HttpResponse messageGot = new HttpResponse(streamResp);
messageGot.getMessage();
return Observable.just(messageGot);
} catch (IOException e) {
return Observable.error(e);
}
},
// Resource dispose
streamResp -> {
try {
streamResp.close();
} catch (IOException ignore) {
// The connection will be closed automatically after timeout,
// the exception in closing can be ignored.
}
});
}