本文整理了Java中com.squareup.okhttp.Request.newBuilder
方法的一些代码示例,展示了Request.newBuilder
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.newBuilder
方法的具体详情如下:
包路径:com.squareup.okhttp.Request
类名称:Request
方法名:newBuilder
暂无
代码示例来源:origin: spinnaker/kayenta
@Override
public Request authenticateProxy(Proxy proxy, Response response) throws IOException {
return response.request().newBuilder().header("Proxy-Authorization", credential).build();
}
});
代码示例来源:origin: spinnaker/kayenta
@Override
public Request authenticate(Proxy proxy, Response response) throws IOException {
return response.request().newBuilder().header("Authorization", credential).build();
}
代码示例来源:origin: net.code-story/fluent-rest-test
@Override
public Request authenticate(Proxy proxy, com.squareup.okhttp.Response response) {
if (tries.getAndIncrement() > 0) {
return null;
}
return addBasicAuthHeader(login, password).apply(response.request().newBuilder()).build();
}
代码示例来源:origin: tomahawk-player/tomahawk-android
@Override
public Request authenticate(Proxy proxy, Response response) throws IOException {
String credential = Credentials.basic(username, password);
return response.request().newBuilder().header("Authorization", credential)
.build();
}
代码示例来源:origin: vinsol-spree-contrib/spree-android
@Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
// Customize the request
Request request = original.newBuilder()
.addHeader(HEADER_API_TOKEN, "8915ef28cf2a154a74e59ce6aada52d0da969126a32d5455")
.build();
Response response = chain.proceed(request);
return response;
}
});
代码示例来源:origin: liferay/liferay-mobile-sdk
@Override
public Request authenticate(Proxy proxy, Response response)
throws IOException {
String credential = Credentials.basic(username, password);
return response.request().newBuilder().header(
Headers.AUTHORIZATION, credential).build();
}
代码示例来源:origin: fr.jcgay.send-notification/send-notification
@Override
public Request authenticate(Proxy proxy, Response response) {
String credentials = Credentials.basic(configuration.key(), "");
if (credentials.equals(response.request().header("Authorization"))) {
return null; // If we already failed with these credentials, don't retry.
}
return response.request().newBuilder().header("Authorization", credentials).build();
}
代码示例来源:origin: xbmc/Kore
@Override
public Request authenticate(Proxy proxy, Response response) throws IOException {
if (TextUtils.isEmpty(hostInfo.getUsername()))
return null;
String credential = Credentials.basic(hostInfo.getUsername(), hostInfo.getPassword());
return response.request().newBuilder().header("Authorization", credential).build();
}
代码示例来源:origin: jcgay/send-notification
@Override
public Request authenticate(Proxy proxy, Response response) {
String credentials = Credentials.basic(configuration.key(), "");
if (credentials.equals(response.request().header("Authorization"))) {
return null; // If we already failed with these credentials, don't retry.
}
return response.request().newBuilder().header("Authorization", credentials).build();
}
代码示例来源:origin: boredream/DesignResCollection
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request().newBuilder()
.addHeader("Content-Type", "application/json")
.addHeader(APP_ID_NAME, APP_ID_VALUE)
.addHeader(API_KEY_NAME, API_KEY_VALUE)
.addHeader(SESSION_TOKEN_KEY, UserInfoKeeper.getToken())
.build();
return chain.proceed(request);
}
});
代码示例来源:origin: PaNaVTEC/Clean-Contacts
private Request composeRequest(Chain chain) {
HttpUrl url = composeUrl(chain);
Request original = chain.request();
return original.newBuilder()
.url(url)
.header("User-Agent", userAgent)
.method(original.method(), original.body())
.build();
}
代码示例来源:origin: kubernetes-client/java
@Override public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
代码示例来源:origin: NightscoutFoundation/xDrip
@Override
public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
代码示例来源:origin: de.adorsys.multibanking/xs2a-adapter
@Override public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
代码示例来源:origin: io.kubernetes/client-java-api
@Override public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
代码示例来源:origin: com.graphhopper/directions-api-client
@Override public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
代码示例来源:origin: AzureAD/azure-activedirectory-library-for-android
@Override public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
代码示例来源:origin: com.neotys.ascode/swagger-java-client
@Override public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
代码示例来源:origin: de.adorsys.multibanking/finapi-adapter
@Override public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
代码示例来源:origin: shinesolutions/swagger-aem
@Override public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
内容来源于网络,如有侵权,请联系作者删除!