de.taimos.httputils.callbacks.HTTPStatusCheckCallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of httputils Show documentation
Show all versions of httputils Show documentation
Utility package for HTTP calls
package de.taimos.httputils.callbacks;
import org.apache.http.HttpResponse;
import de.taimos.httputils.HTTPResponseCallback;
public abstract class HTTPStatusCheckCallback implements HTTPResponseCallback {
@Override
public final void response(HttpResponse response) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != this.expectedStatus()) {
this.invalidStatus(statusCode, response);
}
this.checkedResponse(response);
}
protected abstract void checkedResponse(HttpResponse response);
protected abstract void invalidStatus(int status, HttpResponse response);
/**
* @return the expected status code of the {@link HttpResponse}
*/
protected int expectedStatus() {
return 200;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy