I am writing an application that uses RoboSpice. In the request listener onRequestFailure( SpiceException arg0 ) is there a way to know for sure that the error was a result of a
With google http client for java you can also intercept error responses like so:
public static class InitIntercept implements
HttpRequestInitializer, HttpUnsuccessfulResponseHandler {
@Override
public boolean handleResponse(
HttpRequest request,
HttpResponse response,
boolean retrySupported) throws IOException {
if (response.getStatusCode() == HttpStatusCodes.STATUS_CODE_UNAUTHORIZED) {
...
}
return false;
}
@Override
public void initialize(HttpRequest request) throws IOException {
request.setUnsuccessfulResponseHandler(this);
}
}
and in your GoogleHttpClientSpiceService:
@Override
public HttpRequestFactory createRequestFactory() {
return AndroidHttp
.newCompatibleTransport().createRequestFactory(new InitIntercept());
}