List of usage examples for com.google.gwt.http.client RequestTimeoutException getTimeoutMillis
public int getTimeoutMillis()
From source file:io.reinert.requestor.RequestDispatcherImpl.java
License:Apache License
private <D> RequestCallback getRequestCallback(final Request request, final XMLHttpRequest xhr, final Deferred<D> deferred, final Class<D> resolveType, final Class<?> parametrizedType) { return new RequestCallback() { public void onResponseReceived(com.google.gwt.http.client.Request gwtRequest, com.google.gwt.http.client.Response gwtResponse) { final String responseType = xhr.getResponseType(); final Payload payload = responseType.isEmpty() || responseType.equalsIgnoreCase("text") ? new Payload(xhr.getResponseText()) : new Payload(xhr.getResponse()); final RawResponseImpl response = new RawResponseImpl(gwtResponse.getStatusCode(), gwtResponse.getStatusText(), new Headers(gwtResponse.getHeaders()), ResponseType.of(responseType), payload); evalResponse(request, deferred, resolveType, parametrizedType, response); }//from w w w . jav a2 s . c o m public void onError(com.google.gwt.http.client.Request gwtRequest, Throwable exception) { if (exception instanceof com.google.gwt.http.client.RequestTimeoutException) { // reject as timeout com.google.gwt.http.client.RequestTimeoutException e = (com.google.gwt.http.client.RequestTimeoutException) exception; deferred.reject(new RequestTimeoutException(request, e.getTimeoutMillis())); } else { // reject as generic request exception deferred.reject(new RequestException(exception)); } } }; }