com.squareup.okhttp.Request.headers()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中com.squareup.okhttp.Request.headers方法的一些代码示例,展示了Request.headers的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.headers方法的具体详情如下:
包路径:com.squareup.okhttp.Request
类名称:Request
方法名:headers

Request.headers介绍

暂无

代码示例

代码示例来源:origin: facebook/stetho

@Override
public String headerValue(int index) {
 return mRequest.headers().value(index);
}

代码示例来源:origin: facebook/stetho

@Override
public int headerCount() {
 return mRequest.headers().size();
}

代码示例来源:origin: facebook/stetho

@Override
public String headerName(int index) {
 return mRequest.headers().name(index);
}

代码示例来源:origin: com.github.simonpercic/oklog-java

@Override protected Headers requestHeaders(Request request) {
  return request.headers();
}

代码示例来源:origin: cn-ljb/rxjava_for_android

Headers headers = request.headers();
for (int i = 0, count = headers.size(); i < count; i++) {
  String name = headers.name(i);
} else if (bodyEncoded(request.headers())) {
  logger.log(END + request.method() + " (encoded body omitted)");
} else {

代码示例来源:origin: zalando/logbook

@Override
public Map<String, List<String>> getHeaders() {
  return request.headers().toMultimap();
}

代码示例来源:origin: com.stanfy.helium/helium

private static String getRequestInfo(final Request request, final Response response) {
 final StringBuilder stringBuilder = new StringBuilder();
 stringBuilder.append("\nRequest info: ");
 stringBuilder.append(request.method())
   .append(' ')
   .append(request.urlString())
   .append('\n');
 dumpHeaders(request.headers(), stringBuilder);
 if (request.body() != null) {
  final String loggedEntity = requestBodyToString(request.body());
  if (loggedEntity != null) {
   stringBuilder.append('\n').append(loggedEntity).append('\n');
  }
 }
 stringBuilder.append('\n');
 if (response == null) {
  stringBuilder.append("Response info is not available.");
 } else {
  stringBuilder.append("Response info:\n")
    .append(response.code()).append(" ").append(response.message()).append("\n");
  dumpHeaders(response.headers(), stringBuilder);
  stringBuilder
    .append('\n')
    .append(responseBodyToString(response.body())).append('\n');
 }
 return stringBuilder.toString();
}

代码示例来源:origin: pratamawijaya/example

@Override public Response intercept(Chain chain) throws IOException {
  Request request = chain.request();

  long t1 = System.nanoTime();
  Timber.i(String.format("Sending request %s on %s%n%s", request.url(), chain.connection(),
    request.headers()));

  Response response = chain.proceed(request);

  long t2 = System.nanoTime();
  Timber.i(String.format("Received response for %s in %.1fms%n%s", response.request().url(),
    (t2 - t1) / 1e6d, response.headers()));

  Timber.i("response : " + response.message());

  return response;
 }
}

代码示例来源:origin: com.stanfy.helium/helium

Request request = chain.request();
LOG.info("---> HTTP {} {}", request.method(), request.urlString());
logHeaders(request.headers());
if (request.body() != null) {
 Buffer bodyBuffer = new Buffer();

代码示例来源:origin: Leaking/WeGit

@Override
  public com.squareup.okhttp.Response intercept(Chain chain) throws IOException {
    L.i(TAG,"------getRetrofitWithoutTokenInstance intercept start-------");
    Request request = chain.request();
    request = request.newBuilder()
        .removeHeader("User-Agent")
        .addHeader("User-Agent", "Leaking/1.0")
         //.addHeader("Accept", "application/vnd.github.beta+json")
        .addHeader("Accept", "application/vnd.github.v3.raw")
        .build();
    //此处build之后要返回request覆盖
    L.i(TAG, "Interceptor header = " + request.headers());
    L.i(TAG, "Interceptor request = " + request.toString());
    L.i(TAG,"------getRetrofitWithoutTokenInstance intercept end-------");
    return chain.proceed(request);
  }
});

代码示例来源:origin: com.palantir.remoting2/tracing-okhttp2

@Override
  public Response intercept(Chain chain) throws IOException {
    Request request = chain.request();

    // instrument request
    OpenSpan callState = Tracer.startSpan(request.method() + " " + request.urlString(), SpanType.CLIENT_OUTGOING);
    Request.Builder instrumentedRequest = new Request.Builder()
        .headers(request.headers())
        .url(request.url())
        .method(request.method(), request.body())
        .header(TraceHttpHeaders.TRACE_ID, Tracer.getTraceId())
        .header(TraceHttpHeaders.SPAN_ID, callState.getSpanId())
        .header(TraceHttpHeaders.IS_SAMPLED, Tracer.isTraceObservable() ? "1" : "0");
    if (callState.getParentSpanId().isPresent()) {
      instrumentedRequest.header(TraceHttpHeaders.PARENT_SPAN_ID, callState.getParentSpanId().get());
    }

    Response response;
    try {
      response = chain.proceed(instrumentedRequest.build());
    } finally {
      Tracer.completeSpan();
    }

    return response;
  }
}

代码示例来源:origin: io.macgyver/macgyver-core

Headers headers = request.headers();
for (int i = 0, count = headers.size(); i < count; i++) {
  String name = headers.name(i);
} else if (bodyEncoded(request.headers())) {
  log("--> END " + request.method() + " (encoded body omitted)");
} else {

代码示例来源:origin: apiman/apiman

requestHeaders = followUp.headers().newBuilder();

代码示例来源:origin: io.apiman/apiman-gateway-platforms-servlet

requestHeaders = followUp.headers().newBuilder();

代码示例来源:origin: com.squareup.okhttp/okhttp-urlconnection

requestHeaders = followUp.headers().newBuilder();

相关文章