本文整理汇总了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);
}
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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: 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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}