當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestBuilder.setTimeoutMillis方法代碼示例

本文整理匯總了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);
   }
}
 
開發者ID:openremote,項目名稱:WebConsole,代碼行數:29,代碼來源:JSONControllerConnector.java

示例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);
}
 
開發者ID:growbit,項目名稱:turbogwt-http,代碼行數:17,代碼來源:ServerConnectionImpl.java

示例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();
  }
}
 
開發者ID:mwl,項目名稱:gwt-upload,代碼行數:16,代碼來源:Uploader.java

示例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);
    }
}
 
開發者ID:vaadin,項目名稱:touchkit,代碼行數:13,代碼來源:OfflineModeEntrypoint.java

示例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);
}
 
開發者ID:mwl,項目名稱:gwt-upload,代碼行數:10,代碼來源:Uploader.java

示例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);
}
 
開發者ID:mwl,項目名稱:gwt-upload,代碼行數:21,代碼來源:Uploader.java


注:本文中的com.google.gwt.http.client.RequestBuilder.setTimeoutMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。