Java 类com.squareup.okhttp.Interceptor.Chain 实例源码

项目:gocardless-pro-java    文件:LoggingInterceptor.java   
public Response intercept(Chain chain) throws IOException {
    Request request = chain.request();
    Stopwatch stopwatch = Stopwatch.createStarted();
    Response response = chain.proceed(request);
    stopwatch.stop();
    LOGGER.info("API request [{}] [{}] returned [{}] (took [{}])", request.method(),
            request.url(), response.code(), stopwatch);
    return response;
}
项目:blockscore-java    文件:UserAgentInterceptor.java   
@Override
public Response intercept(Chain chain) throws IOException {
  Request originalRequest = chain.request();
  Request requestWithUserAgent =
              originalRequest.newBuilder()
                             .removeHeader("User-Agent")
                             .addHeader("User-Agent", userAgent)
                             .build();
  return chain.proceed(requestWithUserAgent);
}
项目:FMTech    文件:CurlLoggingInterceptor.java   
public final Response intercept(Interceptor.Chain paramChain)
  throws IOException
{
  Request localRequest = paramChain.request();
  String str1 = VolleyLog.TAG;
  StringBuilder localStringBuilder = new StringBuilder();
  localStringBuilder.append("curl ");
  localStringBuilder.append("-X ");
  localStringBuilder.append(localRequest.method);
  localStringBuilder.append(" ");
  Iterator localIterator = localRequest.headers.names().iterator();
  while (localIterator.hasNext())
  {
    String str4 = (String)localIterator.next();
    localStringBuilder.append("--header \"");
    localStringBuilder.append(str4);
    localStringBuilder.append(": ");
    List localList = localRequest.headers.values(str4);
    int i = localList.size();
    for (int j = 0; j < i; j++)
    {
      localStringBuilder.append((String)localList.get(j));
      if (j < i - 1) {
        localStringBuilder.append(", ");
      }
    }
    localStringBuilder.append("\" ");
  }
  URI localURI = localRequest.uri();
  localStringBuilder.append("\"");
  localStringBuilder.append(localURI);
  localStringBuilder.append("\"");
  ByteArrayOutputStream localByteArrayOutputStream;
  if (localRequest.body != null)
  {
    RequestBody localRequestBody = localRequest.body;
    if (localRequestBody != null)
    {
      if (localRequestBody.contentLength() >= 1024L) {
        break label417;
      }
      localByteArrayOutputStream = new ByteArrayOutputStream();
      Buffer localBuffer = new Buffer();
      localRequestBody.writeTo(localBuffer);
      localBuffer.writeTo(localByteArrayOutputStream, localBuffer.size);
      localBuffer.copyTo(localByteArrayOutputStream, 0L, localBuffer.size);
      if (!isBinaryContent(localRequest.headers, localRequestBody.contentType())) {
        break label389;
      }
      String str3 = Base64.encodeToString(localByteArrayOutputStream.toByteArray(), 2);
      localStringBuilder.insert(0, "echo '" + str3 + "' | base64 -d > /tmp/$$.bin; ");
      localStringBuilder.append(" --data-binary @/tmp/$$.bin");
    }
  }
  for (;;)
  {
    Log.v(str1, localStringBuilder.toString());
    return paramChain.proceed(localRequest);
    label389:
    String str2 = localByteArrayOutputStream.toString();
    localStringBuilder.append(" --data-ascii \"").append(str2).append("\"");
    continue;
    label417:
    localStringBuilder.append(" [TOO MUCH DATA TO INCLUDE]");
  }
}