Examples of XmlHttpRequest


Examples of com.google.gwt.xhr.client.XMLHttpRequest

        return;
      }

      // use XHR to download it

      final XMLHttpRequest xhr = XMLHttpRequest.create();

      xhr.open(HTTP_GET, fragmentUrl);

      xhr.setOnReadyStateChange(new ReadyStateChangeHandler() {
        public void onReadyStateChange(XMLHttpRequest ignored) {
          if (xhr.getReadyState() == XMLHttpRequest.DONE) {
            xhr.clearOnReadyStateChange();
            if ((xhr.getStatus() == HTTP_STATUS_OK || xhr.getStatus() == HTTP_STATUS_NON_HTTP)
                && xhr.getResponseText() != null
                && xhr.getResponseText().length() != 0) {
              try {
                gwtInstallCode(xhr.getResponseText());
              } catch (RuntimeException e) {
                loadErrorHandler.loadFailed(e);
              }
            } else {
              loadErrorHandler.loadFailed(new HttpDownloadFailure(
                  xhr.getStatus()));
            }
          }
        }
      });

      xhr.send();
    }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

        return;
      }

      // use XHR to download it

      final XMLHttpRequest xhr = XMLHttpRequest.create();

      xhr.open(HTTP_GET, fragmentUrl);

      xhr.setOnReadyStateChange(new ReadyStateChangeHandler() {
        public void onReadyStateChange(XMLHttpRequest ignored) {
          if (xhr.getReadyState() == XMLHttpRequest.DONE) {
            xhr.clearOnReadyStateChange();
            if ((xhr.getStatus() == HTTP_STATUS_OK || xhr.getStatus() == HTTP_STATUS_NON_HTTP)
                && xhr.getResponseText() != null
                && xhr.getResponseText().length() != 0) {
              try {
                gwtInstallCode(xhr.getResponseText());
              } catch (RuntimeException e) {
                loadErrorHandler.loadFailed(e);
              }
            } else {
              loadErrorHandler.loadFailed(new HttpDownloadFailure(
                  xhr.getStatus()));
            }
          }
        }
      });

      xhr.send();
    }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

   * @throws NullPointerException if request data has not been set
   * @throws NullPointerException if a request callback has not been set
   */
  private Request doSend(String requestData, final RequestCallback callback)
      throws RequestException {
    XMLHttpRequest xmlHttpRequest = XMLHttpRequest.create();

    try {
      if (user != null && password != null) {
        xmlHttpRequest.open(httpMethod, url, user, password);
      } else if (user != null) {
        xmlHttpRequest.open(httpMethod, url, user);
      } else {
        xmlHttpRequest.open(httpMethod, url);
      }
    } catch (JavaScriptException e) {
      RequestPermissionException requestPermissionException = new RequestPermissionException(
          url);
      requestPermissionException.initCause(new RequestException(e.getMessage()));
      throw requestPermissionException;
    }

    setHeaders(xmlHttpRequest);

    final Request request = new Request(xmlHttpRequest, timeoutMillis, callback);

    // Must set the onreadystatechange handler before calling send().
    xmlHttpRequest.setOnReadyStateChange(new ReadyStateChangeHandler() {
      public void onReadyStateChange(XMLHttpRequest xhr) {
        if (xhr.getReadyState() == XMLHttpRequest.DONE) {
          xhr.clearOnReadyStateChange();
          request.fireOnResponseReceived(callback);
        }
      }
    });

    try {
      xmlHttpRequest.send(requestData);
    } catch (JavaScriptException e) {
      throw new RequestException(e.getMessage());
    }

    return request;
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

      throw new GdxRuntimeException("Unsupported asset type " + type);
    }
  }

  public void loadText (String url, final AssetLoaderListener<String> listener) {
    XMLHttpRequest request = XMLHttpRequest.create();
    request.setOnReadyStateChange(new ReadyStateChangeHandler() {
      @Override
      public void onReadyStateChange (XMLHttpRequest xhr) {
        if (xhr.getReadyState() == XMLHttpRequest.DONE) {
          if (xhr.getStatus() != 200) {
            listener.onFailure();
          } else {
            listener.onSuccess(xhr.getResponseText());
          }
        }
      }
    });
    setOnProgress(request, listener);
    request.open("GET", url);
    request.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
    request.send();
  }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

    request.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
    request.send();
  }

  public void loadBinary (final String url, final AssetLoaderListener<Blob> listener) {
    XMLHttpRequest request = XMLHttpRequest.create();   
    request.setOnReadyStateChange(new ReadyStateChangeHandler() {
      @Override
      public void onReadyStateChange (XMLHttpRequest xhr) {
        if (xhr.getReadyState() == XMLHttpRequest.DONE) {
          if (xhr.getStatus() != 200) {
            listener.onFailure();
          } else {
            Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
            listener.onSuccess(new Blob(data));
          }
        }
      }
    });
    setOnProgress(request, listener);
    request.open("GET", url);
    request.setResponseType(ResponseType.ArrayBuffer);
    request.send();
  }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

     * Setting the onreadystatechange handler to null gives us the correct
     * behavior in Mozilla but crashes IE. That is why we have chosen to fixed
     * this in Java by nulling out our reference to the XmlHttpRequest object.
     */
    if (xmlHttpRequest != null) {
      XMLHttpRequest xmlHttp = xmlHttpRequest;
      xmlHttpRequest = null;

      xmlHttp.clearOnReadyStateChange();
      xmlHttp.abort();

      cancelTimer();
    }
  }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

    /*
     * We cannot use cancel here because it would clear the contents of the
     * JavaScript XmlHttpRequest object so we manually null out our reference to
     * the JavaScriptObject
     */
    final XMLHttpRequest xhr = xmlHttpRequest;
    xmlHttpRequest = null;

    String errorMsg = getBrowserSpecificFailure(xhr);
    if (errorMsg != null) {
      Throwable exception = new RuntimeException(errorMsg);
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

   * @throws NullPointerException if request data has not been set
   * @throws NullPointerException if a request callback has not been set
   */
  private Request doSend(String requestData, final RequestCallback callback)
      throws RequestException {
    XMLHttpRequest xmlHttpRequest = XMLHttpRequest.create();

    try {
      if (user != null && password != null) {
        xmlHttpRequest.open(httpMethod, url, user, password);
      } else if (user != null) {
        xmlHttpRequest.open(httpMethod, url, user);
      } else {
        xmlHttpRequest.open(httpMethod, url);
      }
    } catch (JavaScriptException e) {
      RequestPermissionException requestPermissionException = new RequestPermissionException(
          url);
      requestPermissionException.initCause(new RequestException(e.getMessage()));
      throw requestPermissionException;
    }

    setHeaders(xmlHttpRequest);

    final Request request = new Request(xmlHttpRequest, timeoutMillis, callback);

    // Must set the onreadystatechange handler before calling send().
    xmlHttpRequest.setOnReadyStateChange(new ReadyStateChangeHandler() {
      public void onReadyStateChange(XMLHttpRequest xhr) {
        if (xhr.getReadyState() == XMLHttpRequest.DONE) {
          xhr.clearOnReadyStateChange();
          request.fireOnResponseReceived(callback);
        }
      }
    });

    try {
      xmlHttpRequest.send(requestData);
    } catch (JavaScriptException e) {
      throw new RequestException(e.getMessage());
    }

    return request;
View Full Code Here

Examples of elemental.dom.XMLHttpRequest

      if (getRequestCount() >= requestWarningLimit && !alreadyLoggedError) {
        eventListener.onWarning(this);
        alreadyLoggedError = true;
      }
     
      final XMLHttpRequest xhr = request.getRequest();
      customHeaders.iterate(new IterationCallback<String>() {
        @Override
        public void onIteration(String header, String value) {
          xhr.setRequestHeader(header, value);
        }
      });
    }
View Full Code Here

Examples of elemental.dom.XMLHttpRequest

 
  public void testCustomHeadersInserted() {
    XhrWarden.WardenListener listener = EasyMock.createMock(XhrWarden.WardenListener.class);
    replay(listener);

    XMLHttpRequest mockXHR = EasyMock.createMock(XMLHttpRequest.class);
    mockXHR.setRequestHeader("X-Test", "test");
    replay(mockXHR);
   
    WardenXhrRequest request = createRequest(1, 1);
    expect(request.getRequest()).andReturn(mockXHR).anyTimes();
    replay(request);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.