// Short circuit, no need to wait for response end
if (writeStream == null) {
if (finalExpectedStatuses.contains(response.statusCode())) {
d.resolve(response);
} else {
d.reject(new RejectException().setValue(response));
}
return;
}
Pump.createPump(response, writeStream).start();
response.endHandler(new Handler<Void>() {
@Override
public void handle(Void event) {
if (finalExpectedStatuses.contains(response.statusCode())) {
d.resolve(response);
} else {
d.reject(new RejectException().setValue(response));
}
}
});
});