com.google.gwt.http.client.RequestException Java Examples
The following examples show how to use
com.google.gwt.http.client.RequestException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogStore.java From core with GNU Lesser General Public License v2.1 | 5 votes |
private void doStreamLogFile(final String fileName, final Dispatcher.Channel channel) { RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, encode(streamUrl(fileName))); requestBuilder.setHeader("Accept", "text/plain"); requestBuilder.setHeader("Content-Type", "text/plain"); String bearerToken = DMRHandler.getBearerToken(); if (bearerToken != null) requestBuilder.setHeader("Authorization", "Bearer " + bearerToken); requestBuilder.setIncludeCredentials(true); try { // store the request in order to cancel it later pendingStreamingRequest = new PendingStreamingRequest(fileName, requestBuilder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() >= 400) { channel.nack(new IllegalStateException("Failed to stream log file " + fileName + ": " + response.getStatusCode() + " - " + response.getStatusText())); } else { LogFile newLogFile = new LogFile(fileName, response.getText()); newLogFile.setFollow(false); states.put(fileName, newLogFile); activate(newLogFile); channel.ack(); } } @Override public void onError(Request request, Throwable exception) { channel.nack(exception); } }), channel); } catch (RequestException e) { channel.nack(e); } }