Example usage for com.google.gwt.xhr.client XMLHttpRequest HEADERS_RECEIVED

List of usage examples for com.google.gwt.xhr.client XMLHttpRequest HEADERS_RECEIVED

Introduction

In this page you can find the example usage for com.google.gwt.xhr.client XMLHttpRequest HEADERS_RECEIVED.

Prototype

int HEADERS_RECEIVED

To view the source code for com.google.gwt.xhr.client XMLHttpRequest HEADERS_RECEIVED.

Click Source Link

Document

The HEADERS_RECEIVED state is the state of the object when all response headers have been received.

Usage

From source file:com.gwtpro.html5.fileapi.client.upload.UploadRequest.java

License:Apache License

/**
 * Returns true if this request is waiting for a response.
 * //from   ww w . jav  a  2s.c  o m
 * @return true if this request is waiting for a response
 */
public boolean isPending() {
    if (this.xmlHttpRequest == null) {
        return false;
    }
    int readyState = this.xmlHttpRequest.getReadyState();
    switch (readyState) {
    case XMLHttpRequest.OPENED:
    case XMLHttpRequest.HEADERS_RECEIVED:
    case XMLHttpRequest.LOADING:
        return true;
    }
    return false;
}

From source file:org.atmosphere.gwt.client.impl.HTTPRequestCometTransport.java

License:Apache License

@Override
public void disconnect() {
    aborted = true;//w  w  w.  ja  v a2  s. c  o m
    expectingDisconnection = true;
    super.disconnect();
    if (xmlHttpRequest != null) {
        if (xmlHttpRequest.getReadyState() >= XMLHttpRequest.HEADERS_RECEIVED) {
            //                if readystate >= HEADERS_RECEIVED we can abort otherwise wait for this in onReadyStateChange
            xmlHttpRequest.clearOnReadyStateChange();
            if (xmlHttpRequest.getReadyState() != XMLHttpRequest.DONE) {
                listener.onDisconnected();
                xmlHttpRequest.abort();
            }
            xmlHttpRequest = null;
        } else {
            new Timer() {
                XMLHttpRequest r = xmlHttpRequest;

                @Override
                public void run() {
                    r.clearOnReadyStateChange();
                    if (r.getReadyState() != XMLHttpRequest.DONE
                            && r.getReadyState() != XMLHttpRequest.UNSENT) {
                        listener.onDisconnected();
                        r.abort();
                    }
                    r = null;
                }
            }.schedule(5000);
            xmlHttpRequest = null;
        }
    }
}