本文整理匯總了Java中com.google.gwt.http.client.RequestBuilder.setTimeoutMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java RequestBuilder.setTimeoutMillis方法的具體用法?Java RequestBuilder.setTimeoutMillis怎麽用?Java RequestBuilder.setTimeoutMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.http.client.RequestBuilder
的用法示例。
在下文中一共展示了RequestBuilder.setTimeoutMillis方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doJsonRequest
import com.google.gwt.http.client.RequestBuilder; //導入方法依賴的package包/類
private void doJsonRequest(String url, String username, String password, JSONControllerCallback callback, Integer timeout) {
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
Request request = null;
// Add accept header
builder.setHeader("Accept", "application/json");
if (username != null && username.length() > 0) {
if (password == null) password = "";
// Add authentication header
String authStr = username + ":" + password;
String authEnc = "Basic " + BrowserUtils.base64Encode(authStr);
builder.setHeader("Authorization", authEnc);
}
builder.setCallback(callback);
if (timeout != null) {
builder.setTimeoutMillis(timeout);
}
try {
request = builder.send();
} catch (RequestException e) {
callback.onError(request, e);
}
}
示例2: 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);
}
示例3: update
import com.google.gwt.http.client.RequestBuilder; //導入方法依賴的package包/類
public void update() {
try {
if (waitingForResponse) {
return;
}
waitingForResponse = true;
// Using a reusable builder makes IE fail because it caches the response
// So it's better to change the request path sending an additional random parameter
RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, composeURL("filename=" + fileInput.getName() , "c=" + requestsCounter++));
reqBuilder.setTimeoutMillis(DEFAULT_AJAX_TIMEOUT);
reqBuilder.sendRequest("get_status", onStatusReceivedCallback);
} catch (RequestException e) {
e.printStackTrace();
}
}
示例4: run
import com.google.gwt.http.client.RequestBuilder; //導入方法依賴的package包/類
@Override
public void run() {
RequestBuilder rq = new RequestBuilder(RequestBuilder.POST, getPingUrl());
rq.setTimeoutMillis(offlinePingInterval);
rq.setCallback(OfflineModeEntrypoint.this);
try {
logger.info("Sending a ping request to the server.");
rq.send();
} catch (Exception e) {
onError(null, e);
}
}
示例5: sendAjaxRequestToGetBlobstorePath
import com.google.gwt.http.client.RequestBuilder; //導入方法依賴的package包/類
/**
* Sends a request to the server in order to get the blobstore path.
* When the response with the session comes, it submits the form.
*/
private void sendAjaxRequestToGetBlobstorePath() throws RequestException {
RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, composeURL(PARAM_BLOBSTORE + "=true"));
reqBuilder.setTimeoutMillis(DEFAULT_AJAX_TIMEOUT);
reqBuilder.sendRequest("blobstore", onBlobstoreReceivedCallback);
}
示例6: sendAjaxRequestToValidateSession
import com.google.gwt.http.client.RequestBuilder; //導入方法依賴的package包/類
/**
* Sends a request to the server in order to get the session cookie,
* when the response with the session comes, it submits the form.
*
* This is needed because this client application usually is part of
* static files, and the server doesn't set the session until dynamic pages
* are requested.
*
* If we submit the form without a session, the server creates a new
* one and send a cookie in the response, but the response with the
* cookie comes to the client at the end of the request, and in the
* meanwhile the client needs to know the session in order to ask
* the server for the upload status.
*/
private void sendAjaxRequestToValidateSession() throws RequestException {
// Using a reusable builder makes IE fail
RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, composeURL(PARAM_SESSION + "=true"));
reqBuilder.setTimeoutMillis(DEFAULT_AJAX_TIMEOUT);
reqBuilder.sendRequest("create_session", onSessionReceivedCallback);
}