本文整理汇总了Java中com.google.gwt.http.client.RequestBuilder.Method方法的典型用法代码示例。如果您正苦于以下问题:Java RequestBuilder.Method方法的具体用法?Java RequestBuilder.Method怎么用?Java RequestBuilder.Method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.http.client.RequestBuilder
的用法示例。
在下文中一共展示了RequestBuilder.Method方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startDownloadRequest
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public void startDownloadRequest(String aUrlPrefix, final int aRequestType, Map<String, String> aParams, RequestBuilder.Method aMethod) throws Exception {
final Frame frame = new Frame();
frame.setVisible(false);
frame.addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
Timer timer = new Timer() {
@Override
public void run() {
frame.removeFromParent();
}
};
timer.schedule(2000);
}
});
String query = "";
for (Map.Entry<String, String> ent : aParams.entrySet()) {
query += param(ent.getKey(), ent.getValue()) + "&";
}
query += param(PlatypusHttpRequestParams.TYPE, String.valueOf(aRequestType));
frame.setUrl(apiUrl + aUrlPrefix + "?" + query);
RootPanel.get().add(frame);
}
示例2: syncRequest
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public XMLHttpRequest2 syncRequest(String aUrl, ResponseType aResponseType, String aBody, RequestBuilder.Method aMethod) throws Exception {
final XMLHttpRequest2 req = XMLHttpRequest.create().<XMLHttpRequest2> cast();
aUrl = Loader.URL_QUERY_PROCESSOR.process(aUrl);
req.open(aMethod.toString(), aUrl, false);
interceptRequest(req);
/*
* Since W3C standard about sync XmlHttpRequest and response type. if
* (aResponseType != null && aResponseType != ResponseType.Default)
* req.setResponseType(aResponseType);
*/
req.setRequestHeader("Pragma", "no-cache");
if (aBody != null)
req.send(aBody);
else
req.send();
if (req.getStatus() == Response.SC_OK)
return req;
else
throw new Exception(req.getStatus() + " " + req.getStatusText());
}
示例3: dispatch
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private void dispatch(RequestBuilder.Method method, RequestCallback callback) {
ensureHeaders();
// Execute filters on this request
final List<RequestFilter> filters = filterManager.getRequestFilters();
for (RequestFilter filter : filters) {
filter.filter(this);
}
String body = serializePayload();
ServerConnection connection = server.getConnection();
try {
connection.sendRequest(timeout, user, password, headers, method, uri, body, callback);
} catch (final RequestException e) {
throw new RequestDispatchException("It was not possible to dispatch the request.", e);
}
}
示例4: sendRequest
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override
public void sendRequest(int timeout, @Nullable String user, @Nullable String password, @Nullable Headers headers,
RequestBuilder.Method method, String url, String data, RequestCallback callback)
throws RequestException {
final RequestBuilder requestBuilder = new RequestBuilder(method, url);
if (timeout > 0) requestBuilder.setTimeoutMillis(timeout);
if (user != null) requestBuilder.setUser(user);
if (password != null) requestBuilder.setPassword(password);
if (user != null && password != null) requestBuilder.setIncludeCredentials(true);
if (headers != null) {
for (Header header : headers) {
requestBuilder.setHeader(header.getName(), header.getValue());
}
}
requestBuilder.sendRequest(data, callback);
}
示例5: LASRequestEvent
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public LASRequestEvent(String url, RequestBuilder.Method method,
String requestCallbackObjectName, String sourceName) {
this.url = url;
this.method = method;
this.requestCallbackObjectName = requestCallbackObjectName;
this.requestBuilder = new RequestBuilder(this.method, this.url);
this.sourceName = sourceName;
}
示例6: newAsyncRequest
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override
protected AsyncRequest newAsyncRequest(RequestBuilder.Method method, String url, boolean async) {
if (isWsAgentRequest(url)) {
final String machineToken = appContext.getWorkspace().getRuntime().getMachineToken();
if (!isNullOrEmpty(machineToken)) {
return new MachineAsyncRequest(method, url, false, machineToken);
}
}
if (isModifyingMethod(method)) {
return new CsrfPreventingAsyncModifyingRequest(method, url, async);
}
return super.newAsyncRequest(method, url, async);
}
示例7: doCreateRequest
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override
protected AsyncRequest doCreateRequest(
RequestBuilder.Method method, String url, Object dtoBody, boolean async) {
AsyncRequest request = super.doCreateRequest(method, url, dtoBody, async);
if (!isWsAgentRequest(url) && !keycloakProvider.isKeycloakDisabled()) {
AsyncRequest asyncRequest = new KeycloakAsyncRequest(keycloakProvider, method, url, async);
if (dtoBody != null) {
if (dtoBody instanceof List<?>) {
asyncRequest.data(dtoFactory.toJson((List<?>) dtoBody));
} else if (dtoBody instanceof String) {
asyncRequest.data((String) dtoBody);
} else {
asyncRequest.data(dtoFactory.toJson(dtoBody));
}
asyncRequest.header(HTTPHeader.CONTENT_TYPE, MimeType.APPLICATION_JSON);
} else if (method.equals(RequestBuilder.POST) || method.equals(RequestBuilder.PUT)) {
/*
Here we need to setup wildcard mime type in content-type header, because CORS filter
responses with 403 error in case if user makes POST/PUT request with null body and without
content-type header. Setting content-type header with wildcard mime type solves this problem.
Note, this issue need to be investigated, because the problem may be occurred as a bug in
CORS filter.
*/
asyncRequest.header(HTTPHeader.CONTENT_TYPE, MimeType.WILDCARD);
}
return asyncRequest;
}
return request;
}
示例8: doCreateRequest
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
/**
* Creates new HTTP request to the specified {@code url}.
*
* @param method request method
* @param url request URL
* @param dtoBody the DTO to send as body of the request. Must implement {@link JsonSerializable}
* interface or contain objects that implement it. May be {@code null}.
* @param async if <b>true</b> - request will be sent in asynchronous mode
* @return new {@link AsyncRequest} instance to send POST request
* @throws NullPointerException in case if request {@code method} is {@code null}, reason
* includes:
* <ul>
* <li>Request method should not be a null
* </ul>
*/
protected AsyncRequest doCreateRequest(
RequestBuilder.Method method, String url, Object dtoBody, boolean async) {
Preconditions.checkNotNull(method, "Request method should not be a null");
AsyncRequest asyncRequest = newAsyncRequest(method, url, async);
if (dtoBody != null) {
if (dtoBody instanceof List) {
asyncRequest.data(dtoFactory.toJson((List) dtoBody));
} else if (dtoBody instanceof String) {
asyncRequest.data((String) dtoBody);
} else {
asyncRequest.data(dtoFactory.toJson(dtoBody));
}
asyncRequest.header(HTTPHeader.CONTENT_TYPE, DTO_CONTENT_TYPE);
} else if (method.equals(RequestBuilder.POST) || method.equals(RequestBuilder.PUT)) {
/*
Here we need to setup wildcard mime type in content-type header, because CORS filter
responses with 403 error in case if user makes POST/PUT request with null body and without
content-type header. Setting content-type header with wildcard mime type solves this problem.
Note, this issue need to be investigated, because the problem may be occurred as a bug in
CORS filter.
*/
asyncRequest.header(HTTPHeader.CONTENT_TYPE, MimeType.WILDCARD);
}
return asyncRequest;
}
示例9: getRequestBuilder
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public RequestBuilder getRequestBuilder(String urlPostfix, RequestBuilder.Method m) {
String url = urlPostfix == null ? getUrl() : getUrl() + urlPostfix;
RequestBuilder builder = new RequestBuilder(m, url);
if (OauthClient.checkAuthentication() == null) return null;
String authorization = "GoogleLogin auth=" + OauthClient.checkAuthentication().getAccessToken();
if (LocalSettings.getInstance().getOnBehalfOf() != null) {
authorization = LocalSettings.getInstance().getOnBehalfOf();
}
builder.setHeader("Authorization", authorization);
builder.setHeader("Accept", "application/json");
return builder;
}
示例10: getRequestBuilderEvenIfNotAuthenticated
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public RequestBuilder getRequestBuilderEvenIfNotAuthenticated(String urlPostfix, RequestBuilder.Method m) {
String url = urlPostfix == null ? getUrl() : getUrl() + urlPostfix;
RequestBuilder builder = new RequestBuilder(m, url);
String authorization = "GoogleLogin auth=" + Authentication.getInstance().getAuthenticationToken();
if (LocalSettings.getInstance().getOnBehalfOf() != null) {
authorization = LocalSettings.getInstance().getOnBehalfOf();
}
builder.setHeader("Authorization", authorization);
builder.setHeader("Accept", "application/json");
return builder;
}
示例11: startApiRequest
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public Cancellable startApiRequest(String aUrlPrefix, final String aUrlQuery, String aBody, RequestBuilder.Method aMethod, String aContentType, Callback<XMLHttpRequest, XMLHttpRequest> aCallback)
throws Exception {
String url = apiUrl + (aUrlPrefix != null ? aUrlPrefix : "") + (aUrlQuery != null ? "?" + aUrlQuery : "");
final XMLHttpRequest req = XMLHttpRequest.create();
req.open(aMethod.toString(), url);
if (aContentType != null && !aContentType.isEmpty()) {
req.setRequestHeader("Content-Type", aContentType);
}
interceptRequest(req);
req.setRequestHeader("Pragma", "no-cache");
return startRequest(req, aBody, aCallback);
}
示例12: send
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private <T, C extends Collection> RequestPromise<Collection<T>> send(RequestBuilder.Method method,
Class<T> responseType,
Class<C> containerType) {
final DeferredCollectionResult<T> deferred = new DeferredCollectionResult<T>(responseType, containerType,
serdesManager, containerFactoryManager);
RequestCallback callback = createRequestCallback(deferred);
dispatch(method, callback);
return deferred;
}
示例13: sendRequest
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override
public void sendRequest(RequestBuilder.Method method, String url, String data, RequestCallback callback)
throws RequestException {
ServerStub.setRequestData(url, new RequestMock(method, url, data));
uri = url;
requestCallback = (RequestCallbackWithProgress) callback;
}
示例14: getMethod
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
/**
* @return the method
*/
public RequestBuilder.Method getMethod() {
return method;
}
示例15: setMethod
import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
/**
* @param method
* the method to set
*/
void setMethod(RequestBuilder.Method method) {
this.method = method;
this.requestBuilder = new RequestBuilder(this.method, this.url);
}