本文整理了Java中com.squareup.okhttp.Request.body
方法的一些代码示例,展示了Request.body
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.body
方法的具体详情如下:
包路径:com.squareup.okhttp.Request
类名称:Request
方法名:body
暂无
代码示例来源:origin: facebook/stetho
@Nullable
@Override
public byte[] body() throws IOException {
RequestBody body = mRequest.body();
if (body == null) {
return null;
}
OutputStream out = mRequestBodyHelper.createBodySink(firstHeaderValue("Content-Encoding"));
BufferedSink bufferedSink = Okio.buffer(Okio.sink(out));
try {
body.writeTo(bufferedSink);
} finally {
bufferedSink.close();
}
return mRequestBodyHelper.getDisplayBody();
}
代码示例来源:origin: zalando/logbook
private Optional<MediaType> contentType() {
return Optional.ofNullable(request.body())
.map(RequestBody::contentType);
}
代码示例来源:origin: com.github.simonpercic/oklog-java
@Override protected long requestContentLength(Request request) throws IOException {
return request.body().contentLength();
}
代码示例来源:origin: com.github.simonpercic/oklog-java
@Override protected MediaType requestContentType(Request request) {
return request.body().contentType();
}
代码示例来源:origin: cn-ljb/rxjava_for_android
boolean logHeaders = logBody || level == Level.HEADERS;
RequestBody requestBody = request.body();
boolean hasRequestBody = requestBody != null;
代码示例来源: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: 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: 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: zalando/logbook
@Override
public HttpRequest withBody() throws IOException {
@Nullable final RequestBody body = request.body();
if (body == null) {
this.body = new byte[0];
} else {
final byte[] bytes = bytes(body);
this.request = request.newBuilder()
.method(request.method(), create(body.contentType(), bytes))
.build();
this.body = bytes;
}
return this;
}
代码示例来源:origin: com.walmartlabs.concord/concord-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: org.renci.io.swagger/swagger-java-comet-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: jamorham/xDrip-plus
@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: 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: 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);
}
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!