本文整理了Java中elemental2.dom.XMLHttpRequest
类的一些代码示例,展示了XMLHttpRequest
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLHttpRequest
类的具体详情如下:
包路径:elemental2.dom.XMLHttpRequest
类名称:XMLHttpRequest
暂无
代码示例来源:origin: com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(ArrayBufferView data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
代码示例来源:origin: org.jboss.hal/hal-dmr
private XMLHttpRequest newXhr(String url, HttpMethod method, Operation operation, OnError error, OnLoad onLoad) {
XMLHttpRequest xhr = new XMLHttpRequest();
// The order of the XHR methods is important! Do not rearrange the code unless you know what you're doing!
xhr.onload = event -> onLoad.onLoad(xhr);
xhr.addEventListener("error", //NON-NLS
event -> handleErrorCodes(url, (int) xhr.status, operation, error), false);
xhr.open(method.name(), url, true);
xhr.setRequestHeader(X_MANAGEMENT_CLIENT_NAME.header(), HEADER_MANAGEMENT_CLIENT_VALUE);
String bearerToken = getBearerToken();
if (bearerToken != null) {
xhr.setRequestHeader("Authorization", "Bearer " + bearerToken);
}
xhr.withCredentials = true;
return xhr;
}
代码示例来源:origin: DominoKit/domino-ui
public FileItem cancel() {
if (request != null) {
canceled = true;
request.abort();
}
return this;
}
代码示例来源:origin: org.jresearch.dominokit/domino-ui
};
request.addEventListener("readystatechange", evt -> {
if (request.readyState == 4) {
if (request.status == 200)
request.open("post", options.getUrl());
FormData formData = new FormData();
formData.append(file.name, file);
beforeUploadHandlers.forEach(handler -> handler.onBeforeUpload(request));
request.send(formData);
代码示例来源:origin: intendia-oss/autorest
Map<String, String> headers = new HashMap<>();
for (Param h : headerParams) headers.put(h.k, Objects.toString(h.v));
for (Map.Entry<String, String> h : headers.entrySet()) xhr.setRequestHeader(h.getKey(), h.getValue());
};
em.setCancellable(() -> {
if (xhr.readyState != XMLHttpRequest.DONE) xhr.abort();
});
xhr.setRequestHeader(CONTENT_TYPE, MULTIPART_FORM_DATA);
FormData form = new FormData();
formParams.forEach(p -> form.append(p.k, Objects.toString(p.v)));
xhr.send(form);
} else {
if (!headers.containsKey(CONTENT_TYPE)) xhr.setRequestHeader(CONTENT_TYPE, APPLICATION_JSON);
if (!headers.containsKey(ACCEPT)) xhr.setRequestHeader(ACCEPT, APPLICATION_JSON);
if (data != null) xhr.send(Global.JSON.stringify(data));
else xhr.send();
代码示例来源:origin: org.jboss.hal/hal-dmr
@JsIgnore
public void download(Operation operation, Consumer<String> success) {
Operation downloadOperation = runAs(operation);
String url = downloadUrl(downloadOperation);
XMLHttpRequest request = newXhr(url, GET, downloadOperation, exceptionCallback, xhr -> {
int status = (int) xhr.status;
String responseText = xhr.responseText;
if (status == 200) {
success.accept(responseText);
} else {
handleErrorCodes(url, status, downloadOperation, exceptionCallback);
}
});
request.setRequestHeader(ACCEPT.header(), APPLICATION_DMR_ENCODED);
request.setRequestHeader(CONTENT_TYPE.header(), APPLICATION_DMR_ENCODED);
request.send();
// Downloads are not supported in macros!
}
代码示例来源:origin: org.jresearch.dominokit/domino-ui
public FileItem(File file, UploadOptions options) {
this.file = file;
this.options = options;
initFileImage();
initFileTitle();
initFileSizeParagraph();
initFooter();
initProgress();
initThumbnail();
if (isExceedsMaxFile()) {
invalidate("File is too large, maximum file size is " + formatSize(options.getMaxFileSize()));
}
request =new XMLHttpRequest();
init(this);
}
代码示例来源:origin: DominoKit/domino-ui
};
request.addEventListener("readystatechange", evt -> {
if (request.readyState == 4) {
if (request.status == 200)
request.open("post", options.getUrl());
FormData formData = new FormData();
formData.append(file.name, file);
beforeUploadHandlers.forEach(handler -> handler.onBeforeUpload(request));
request.send(formData);
代码示例来源:origin: org.jboss.hal/hal-dmr
private Single<ModelNode> dmr(Operation operation) {
Operation dmrOperation = runAs(operation); // runAs might mutate the operation, so do it synchronously
boolean get = GetOperation.isSupported(dmrOperation.getName());
String url = get ? operationUrl(dmrOperation) : endpoints.dmr();
HttpMethod method = get ? GET : POST;
// ^-- those eager fields are useful if we don't want to evaluate it on each Single subscription
return Single.fromEmitter(emitter -> {
// in general, code inside the RX type should be able to be executed multiple times and always returns
// the same result, so we need to be careful to not mutate anything (like the operation). This is useful
// for example if we want to use the retry operator which will try again (subscribe again) if it fails.
XMLHttpRequest xhr = newDmrXhr(url, method, dmrOperation, new DmrPayloadProcessor(), emitter::onSuccess,
(op, fail) -> emitter.onError(new DispatchFailure(fail, operation)),
(op, error) -> emitter.onError(error));
xhr.setRequestHeader(ACCEPT.header(), APPLICATION_DMR_ENCODED);
xhr.setRequestHeader(CONTENT_TYPE.header(), APPLICATION_DMR_ENCODED);
if (get) {
xhr.send();
} else {
xhr.send(dmrOperation.toBase64String());
}
recordOperation(operation);
});
}
代码示例来源:origin: DominoKit/domino-ui
public FileItem(File file, UploadOptions options) {
this.file = file;
this.options = options;
initFileImage();
initFileTitle();
initFileSizeParagraph();
initFooter();
initProgress();
initThumbnail();
if (isExceedsMaxFile()) {
invalidate("File is too large, maximum file size is " + formatSize(options.getMaxFileSize()));
}
request =new XMLHttpRequest();
init(this);
}
代码示例来源:origin: com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(Document data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
代码示例来源:origin: org.jresearch.dominokit/domino-ui
public FileItem cancel() {
if (request != null) {
canceled = true;
request.abort();
}
return this;
}
代码示例来源:origin: com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(String data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
代码示例来源:origin: org.realityforge.com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(String data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
代码示例来源:origin: com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(ArrayBuffer data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
代码示例来源:origin: com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(Blob data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
代码示例来源:origin: org.realityforge.com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(ArrayBuffer data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
代码示例来源:origin: org.realityforge.com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(ArrayBufferView data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
代码示例来源:origin: org.realityforge.com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(Blob data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
代码示例来源:origin: org.realityforge.com.google.elemental2/elemental2-dom
@JsOverlay
public final void send(Document data) {
send(Js.<XMLHttpRequest.SendDataUnionType>uncheckedCast(data));
}
内容来源于网络,如有侵权,请联系作者删除!