Thursday, November 9, 2017

Re: XMLHttpRequest getResponse instead of getResponseText to get arraybuffer data


I was wondering if you could advise how one might access the responseURL property that I can see in a Response object in the inspector.
This is the final url from redirects when you access, for example, a google drive image.
One could use these urls as permalinks to their drive images. (Not what Google want I guess).


On Monday, 4 June 2012 23:59:35 UTC+10, Thomas Broyer wrote:

On Monday, June 4, 2012 2:53:28 PM UTC+2, Magallo wrote:
Hi, I tried to use your solution. Looking at Google I/O on youtube ( I saw this but I wasn't able to do it.

I tried creating this:

public class BinaryXMLHttpRequest extends XMLHttpRequest
    public native JavaScriptObject getResponse()
        return this.response;
    //Set to "arraybuffer" or "blob" for binary response
    public native void setResponseType(String value)
       this.responseType = value;

then I used this class this way:

BinaryXMLHttpRequest binxhr = (BinaryXMLHttpRequest)BinaryXMLHttpRequest.create();"GET", "myservlet_url");
binxhr.setOnReadyStateChange(new ReadyStateChangeHandler()
     public void onReadyStateChange(XMLHttpRequest xhr)
         BinaryXMLHttpRequest binxhr = (BinaryXMLHttpRequest)xhr;
         if( binxhr.getReadyState() == XMLHttpRequest.DONE )
             binxhr.getResponse(); => what can I do with this?

If you look, at the end I have a binxhr.getResponse(); But this function returna a JavaScriptObject type. What can I do now with this? This is not a byte[] or whatever, so, I don't know in GWT how to manipulate it. Do you have an idea?

It will be an ArrayBuffer, so you'd have to build a JSO overlay type representing ArrayBuffer and cast() the JSO to your ArrayBuffer.

But honestly, it'd be easier to compile GWT from trunk and use the API that's already in there. When 2.5 will be out the doors, simply replace your home-built pre-2.5 GWT with the official 2.5.

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment