okhttp3.Request.toString()方法的使用及代码示例

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

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

Request.toString介绍

暂无

代码示例

代码示例来源:origin: radixdlt/radixdlt-java

@Override
  public String toString() {
    return endpoint.toString();
  }
}

代码示例来源:origin: wangli135/BlogDemo

@Override
  public Response intercept(Chain chain) throws IOException {

    Request request = chain.request();

    System.out.println(request.toString());
    
    Response response = chain.proceed(request);

    System.out.println(response);

    return response;
  }
}

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

@Override
  public Response intercept(Chain chain) throws IOException {
    requireNonNull(chain, "chain must be defined.");
    if (httpRequester.isDebugEnabled()) {
      httpRequester.debug("Request : {}", chain.request().toString());
    }
    return chain.proceed(chain.request());
  }
};

代码示例来源:origin: hejunlin2013/TVSample

public static void asyncGet(Request request, Callback callback) {
  Log.d(REQUEST_TAG, "async request Url: " + request.toString());
  AppManager.getHttpClient().newCall(request).enqueue(callback);
}

代码示例来源:origin: SmithGao/rxjava_retrofit3.0_okhttp

@Override
    public okhttp3.Response intercept(Chain chain) throws IOException {
      Request request = chain.request();
      Log.e(TAG, "okhttp3:" + request.toString());//输出请求前整个url
      long t1 = System.nanoTime();
      okhttp3.Response response = chain.proceed(chain.request());
      long t2 = System.nanoTime();
//            Log.v(TAG,response.request().url()+response.headers());//输出一个请求的网络信息
      okhttp3.MediaType mediaType = response.body().contentType();
      String content = response.body().string();
      Log.e(TAG, "response body:" + content);//输出返回信息
      return response.newBuilder()
          .body(okhttp3.ResponseBody.create(mediaType, content))
          .build();
    }
  }

代码示例来源:origin: hejunlin2013/TVSample

public static String syncGet(String url) {
  Request request = buildRequest(url);
  Log.d(REQUEST_TAG, "sync request Url: " + request.toString());
  try {
    Response response = AppManager.getHttpClient().newCall(request).execute();
    if (response.code() == 200) {
      String ret = new String(response.body().bytes(), "utf-8");
      return ret;
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: XunMengWinter/Now

@Override
  public Response intercept(Chain chain) throws IOException {
    Request request = chain.request();
    Logger.i(request.toString());
    Response response = chain.proceed(request);
    Logger.i(response.toString());
    return response;
  }
});

代码示例来源:origin: 7449/Retrofit_RxJava_MVP

@Override
  public okhttp3.Response intercept(Chain chain) throws IOException {
    Request request = chain.request();
    LogUtils.i("LogUtils--> ", "request:" + request.toString());
    okhttp3.Response response = chain.proceed(chain.request());
    okhttp3.MediaType mediaType = response.body().contentType();
    String content = response.body().string();
    LogUtils.i("LogUtils--> ", "response body:" + content);
    if (response.body() != null) {
      ResponseBody body = ResponseBody.create(mediaType, content);
      return response.newBuilder().body(body).build();
    } else {
      return response;
    }
  }
}

代码示例来源:origin: org.nuxeo.client/nuxeo-java-client

/**
 * Compute the cache key with request
 */
protected String computeCacheKey(Call<?> call) {
  Request originalRequest = call.request();
  MessageDigest digest;
  try {
    digest = MessageDigest.getInstance(ConstantsV1.MD_5);
  } catch (NoSuchAlgorithmException e) {
    return null;
  }
  digest.update((originalRequest.toString() + originalRequest.headers().toString()).getBytes());
  byte[] messageDigest = digest.digest();
  StringBuilder hexString = new StringBuilder();
  for (byte msg : messageDigest) {
    hexString.append(String.format("%02X", msg));
  }
  return hexString.toString();
}

代码示例来源:origin: contentful/contentful.java

private String createString() {
 return format(
   Locale.getDefault(),
   "FAILED REQUEST:\n\t%s\n\t╰→ Header{%s}\n\t%s\n\t├→ Body{%s}\n\t╰→ Header{%s}",
   request.toString(),
   headersToString(request.headers()),
   response.toString(),
   responseBody,
   headersToString(response.headers()));
}

代码示例来源:origin: com.contentful.java/java-sdk

private String createString() {
 return format(
   Locale.getDefault(),
   "FAILED REQUEST:\n\t%s\n\t╰→ Header{%s}\n\t%s\n\t├→ Body{%s}\n\t╰→ Header{%s}",
   request.toString(),
   headersToString(request.headers()),
   response.toString(),
   responseBody,
   headersToString(response.headers()));
}

代码示例来源:origin: hejunlin2013/TVSample

public static void asyncGet(Request request, final Activity activity, final Callback callback) {
  Log.d(REQUEST_TAG, "async request Url: " + request.toString());
  AppManager.getHttpClient().newCall(request).enqueue(new Callback() {
    Handler mainHandler = new Handler(activity.getMainLooper());
    @Override
    public void onFailure(final Call call, final IOException e) {
      mainHandler.post(new Runnable() {
        @Override
        public void run() {
          callback.onFailure(call, e);
        }
      });
    }
    @Override
    public void onResponse(final Call call, final Response response) throws IOException {
      mainHandler.post(new Runnable() {
        @Override
        public void run() {
          try {
            callback.onResponse(call, response);
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      });
    }
  });
}

代码示例来源:origin: com.github.macgregor/alexandria-core

@Override
  public String toString() {
    String metadataString = null;
    if(metadata.isPresent()){
      try{
        metadataString = Jackson.jsonMapper().writer().withDefaultPrettyPrinter().writeValueAsString(metadata.get());
      } catch(JsonProcessingException e){
        metadataString = metadata.get().toString();
      }
    }
    return "HttpException{\n" +
        "   message=\"" + ExceptionUtils.getMessage(this) + "\",\n" +
        "   rootCauseMessage=\"" + ExceptionUtils.getRootCauseMessage(this) + "\",\n" +
        "   metadata=\n" + metadataString + "\n" +
        "   request=" + (request.isPresent() ? request.get().toString() : null) + "\n" +
        "   response=" + (response.isPresent() ? response.get().toString() : null) + "\n" +
        "}\n";
  }
}

代码示例来源:origin: stackoverflow.com

.build();
android.util.Log.e("request - ", "request - " + request.toString());
android.util.Log.e("headers - ", "headers - " + request.headers().toString());
android.util.Log.e("body - ", "body - " + request.body().toString());

代码示例来源:origin: tomasbjerre/git-changelog-lib

throw new GitChangelogIntegrationException(
  "Request:"
    + response.raw().request().toString()
    + "\nError:\n"
    + response.errorBody().string());

代码示例来源:origin: com.github.macgregor/alexandria-core

log.debug(request.toString());
if(request.body() != null) {
  try {

代码示例来源:origin: mapbox/mapbox-java

@Test
public void build_doesAddCoordinatesToUrl() throws Exception {
 MapboxOptimization client = MapboxOptimization.builder()
  .coordinate(Point.fromLngLat(1.23456, 1.23456))
  .coordinate(Point.fromLngLat(20.9876, 20.9876))
  .accessToken(ACCESS_TOKEN)
  .build();
 assertTrue(client.cloneCall().request().toString().contains("1.23456,1.23456;20.9876,20.9876"));
}

相关文章