I'm working on a GWT App that makes a REST call for binary data. I'm trying to use GWT's RequestBuilder. The problem is that the response only offers a getText() method.
Here's the simplest example that reproduces the problem:
private static void sendRequest()
{
String url = URL.encode("/object/object_id");
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
try
{
requestBuilder.sendRequest("", new RequestCallback()
{
@Override
public void onResponseReceived(Request request, Response response)
{
String data = response.getText(); ///< Need this to be a byte[] array (e.g. getData())
}
@Override
public void onError(Request request, Throwable exception)
{
}
});
}
catch (RequestException RequestException)
{
}
}
The problem is that GWT is encoding the response data as a String in (what I think) is the default platform's encoding. Is there any way to get the data before GWT converts it to a String?