I require retrying to send a GWT RPC request if it fails (any response code other then HTTP 200). Reasons are complex so I won't elaborate on that. What I have so far is I treat all request responses in the same place like this:
// We override the RpcRequestBuilder.doSetCallback method and force your service to use it
// With this we can read the response headers if we need to.
((ServiceDefTarget)serviceRPC).setRpcRequestBuilder(new RpcRequestBuilder() {
@Override
protected void doSetCallback(RequestBuilder rb, final RequestCallback callback) {
super.doSetCallback(rb, new RequestCallback() {
@Override
public void onResponseReceived(Request request,
Response response) {
httpResponseOkHandler(callback, request, response);
}
@Override
public void onError(Request request, Throwable exception) {
httpResponseErrorHandler(callback, request, exception);
}
});
}
});
So, using httpResponseOkHandler method, I can catch HTTP failures. But, is there a way to "rethrow" the Request, i.e. try again? I don't want to store the high level parameters of the RPC request, I would prefer to use the request content that was already streamed and ready to resend.
Any ideas?