当前位置: 首页>>代码示例>>Java>>正文


Java RequestBuilder.setHeader方法代码示例

本文整理汇总了Java中com.google.gwt.http.client.RequestBuilder.setHeader方法的典型用法代码示例。如果您正苦于以下问题:Java RequestBuilder.setHeader方法的具体用法?Java RequestBuilder.setHeader怎么用?Java RequestBuilder.setHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.http.client.RequestBuilder的用法示例。


在下文中一共展示了RequestBuilder.setHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testManualSend

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public void testManualSend() throws RequestException {
	RemoteServiceServletTestServiceAsync service = getAsyncService();

	delayTestFinishForRpc();

	RequestBuilder builder = service
			.testExpectCustomHeader(new AsyncCallback<Void>() {

				@Override
				public void onFailure(Throwable caught) {
					TestSetValidator.rethrowException(caught);
				}

				@Override
				public void onSuccess(Void result) {
					assertTrue(!RemoteServiceServletTest.this.req
							.isPending());
					finishTest();
				}
			});

	builder.setHeader("X-Custom-Header", "true");
	this.req = builder.send();
	assertTrue(this.req.isPending());
}
 
开发者ID:jcricket,项目名称:gwt-syncproxy,代码行数:26,代码来源:RemoteServiceServletTest.java

示例3: 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

示例4: buildMultipart

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private RequestBuilder buildMultipart( String name, String value )
{
	String boundary = "AJAX------" + Math.random() + "" + new Date().getTime();

	RequestBuilder builderPost = new RequestBuilder( RequestBuilder.POST, url );
	builderPost.setHeader( "Content-Type", "multipart/form-data; charset=utf-8; boundary=" + boundary );
	builderPost.setCallback( requestCallback );

	String CRLF = "\r\n";
	String data = "--" + boundary + CRLF;
	data += "--" + boundary + CRLF;

	data += "Content-Disposition: form-data; ";
	data += "name=\"" + name + "\"" + CRLF + CRLF;
	data += value + CRLF;
	data += "--" + boundary + "--" + CRLF;

	builderPost.setRequestData( data );

	return builderPost;
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:22,代码来源:RPCBatchRequestSender.java

示例5: filter

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override
public boolean filter(Method method, RequestBuilder builder) {
  if(SessionStorage.getSession() != null)
    builder.setHeader(UserSession.SESSION_HEADER, 
        SessionStorage.getSession().getSessionString());
  return true;
}
 
开发者ID:KnowledgeCaptureAndDiscovery,项目名称:ontosoft,代码行数:8,代码来源:SessionFilter.java

示例6: sendJSON

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private <T extends JavaScriptObject> void sendJSON(
    Method method, JavaScriptObject content, HttpCallback<T> cb) {
  HttpImpl<T> httpCallback = new HttpImpl<>(background, cb);
  try {
    if (!background) {
      RpcStatus.INSTANCE.onRpcStart();
    }
    RequestBuilder req = request(method);
    req.setHeader("Content-Type", JSON_UTF8);
    req.sendRequest(str(content), httpCallback);
  } catch (RequestException e) {
    httpCallback.onError(null, e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:RestApi.java

示例7: sendText

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private <T extends JavaScriptObject> void sendText(
    Method method, String body, HttpCallback<T> cb) {
  HttpImpl<T> httpCallback = new HttpImpl<>(background, cb);
  try {
    if (!background) {
      RpcStatus.INSTANCE.onRpcStart();
    }
    RequestBuilder req = request(method);
    req.setHeader("Content-Type", TEXT_UTF8);
    req.sendRequest(body, httpCallback);
  } catch (RequestException e) {
    httpCallback.onError(null, e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:RestApi.java

示例8: request

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private RequestBuilder request(Method method) {
  RequestBuilder req = new RequestBuilder(method, url());
  if (ifNoneMatch != null) {
    req.setHeader("If-None-Match", ifNoneMatch);
  }
  req.setHeader("Accept", JSON_TYPE);
  if (Gerrit.getXGerritAuth() != null) {
    req.setHeader(HostPageData.XSRF_HEADER_NAME, Gerrit.getXGerritAuth());
  }
  return req;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:RestApi.java

示例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;
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:13,代码来源:GenericClient.java

示例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;
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:12,代码来源:GenericClient.java

示例11: submitRegistration

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public void submitRegistration(UserResults userResults, RegistrationListener registrationListener, final String reportDateFormat) {
    final String registratinoUrl = serviceLocations.registrationUrl();
    final RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, registratinoUrl);
    builder.setHeader("Content-type", "application/x-www-form-urlencoded");
    StringBuilder stringBuilder = new StringBuilder();
    for (String key : userResults.getMetadataKeys()) {
        String value = URL.encodeQueryString(userResults.getMetadataValue(key));
        if (stringBuilder.length() > 0) {
            stringBuilder.append("&");
        }
        stringBuilder.append(key).append("=").append(value);
    }
    if (stringBuilder.length() > 0) {
        stringBuilder.append("&");
    }
    stringBuilder.append("applicationversion").append("=").append(version.projectVersion()).append("&");
    String scoreLog = URL.encodeQueryString(userResults.getScoreLog());
    stringBuilder.append("scorelog").append("=").append(scoreLog).append("&");
    String restultsData = URL.encodeQueryString(new ResultsSerialiser() {
        final DateTimeFormat format = DateTimeFormat.getFormat(reportDateFormat);

        @Override
        protected String formatDate(Date date) {
            return format.format(date);
        }
    }.serialise(userResults, mateadataFields.postName_email()));
    stringBuilder.append("quiz_results=").append(restultsData);
    try {
        builder.sendRequest(stringBuilder.toString(), geRequestBuilder(builder, registrationListener, registratinoUrl));
    } catch (RequestException exception) {
        registrationListener.registrationFailed(new RegistrationException(RegistrationException.ErrorType.buildererror, exception));
        logger.log(Level.SEVERE, "SubmitRegistration", exception);
    }
}
 
开发者ID:languageininteraction,项目名称:GraphemeColourSynaesthesiaApp,代码行数:35,代码来源:RegistrationService.java

示例12: doCreate

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override
protected RequestBuilder doCreate(String serviceEntryPoint) {

    RequestBuilder builder = super.doCreate(serviceEntryPoint);
    builder.setHeader("rv_access_token", getAccessToken()); 
    return builder;

}
 
开发者ID:Rise-Vision,项目名称:rva,代码行数:9,代码来源:OAuth2ServiceWrapper.java

示例13: sendRequest

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private void sendRequest(String url, RequestCallback callback) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
    builder.setHeader("Accept", "application/json");
    
    builder.setUser("ipv6Rest");
    builder.setPassword("ipv6Rest");
    try {
        builder.sendRequest(null, callback);
    } catch (RequestException e) {
        e.printStackTrace();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:13,代码来源:DefaultChartService.java

示例14: sendRequest

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private void sendRequest(RequestCallback callback, String url) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
    builder.setHeader("accept", "application/json");
    try {
        builder.sendRequest(null, callback);
    } catch (RequestException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:11,代码来源:DefaultNodeService.java

示例15: sendRequest

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private void sendRequest(final RequestCallback callback, final Method method, final String url) {
    final RequestBuilder builder = new RequestBuilder(method, url);
    builder.setHeader("accept", "application/json");
    try {
        builder.sendRequest(null, callback);
    } catch (final RequestException e) {
        e.printStackTrace();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:10,代码来源:DefaultKscReportService.java


注:本文中的com.google.gwt.http.client.RequestBuilder.setHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。