com.github.kevinsawicki.http.HttpRequest.readTimeout()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(166)

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

HttpRequest.readTimeout介绍

[英]Set read timeout on connection to given value
[中]将连接上的读取超时设置为给定值

代码示例

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

/**
 * Share the stats to share URL. Must not be called if sharing is disabled.
 * shareEnabled check is not done to avoid double checking.
 */
private void shareStats() {
  try {
    int code = HttpRequest.post(shareURL)
        .connectTimeout(5000)
        .readTimeout(5000)
        .send(objectMapper.writer().writeValueAsString(stats).getBytes(Charsets.UTF_8))
        .code();
    if (code >= 400) {
      logger.info("sharing stats on {} failed. Response code: {}", shareURL, code);
    }
  } catch (Exception e) {
    logger.info("sharing stats on {} failed. Exception: {}", shareURL, e.getMessage());
  }
}

代码示例来源:origin: BoD/jraf-android-util

public static void setDefaultOptions(HttpRequest req) throws IOException {
  req.userAgent(HTTP_USER_AGENT);
  req.connectTimeout(CONNECT_TIMEOUT);
  req.readTimeout(READ_TIMEOUT);
  req.acceptGzipEncoding();
  req.uncompress(true);
  req.trustAllCerts();
  req.trustAllHosts();
}

代码示例来源:origin: ihaolin/antares

private String doPost() {
  HttpRequest post = HttpRequest.post(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  setOptionalHeaders(post);
  if (!Strings.isNullOrEmpty(body)){
    post.send(body);
  }
  if (ssl){
    trustHttps(post);
  }
  return post.body();
}

代码示例来源:origin: ihaolin/antares

private String doGet() {
  HttpRequest get = HttpRequest.get(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  if (ssl){
    trustHttps(get);
  }
  setOptionalHeaders(get);
  return get.body();
}

代码示例来源:origin: me.hao0/common

private String doGet() {
  HttpRequest get = HttpRequest.get(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  if (ssl){
    trustHttps(get);
  }
  setOptionalHeaders(get);
  return get.body();
}

代码示例来源:origin: ihaolin/common

private String doGet() {
  HttpRequest get = HttpRequest.get(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  if (ssl){
    trustHttps(get);
  }
  setOptionalHeaders(get);
  return get.body();
}

代码示例来源:origin: ihaolin/common

private String doPost() {
  HttpRequest post = HttpRequest.post(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  setOptionalHeaders(post);
  if (!Strings.isNullOrEmpty(body)){
    post.send(body);
  }
  if (ssl){
    trustHttps(post);
  }
  return post.body();
}

代码示例来源:origin: me.hao0/common

private String doPost() {
  HttpRequest post = HttpRequest.post(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  setOptionalHeaders(post);
  if (!Strings.isNullOrEmpty(body)){
    post.send(body);
  }
  if (ssl){
    trustHttps(post);
  }
  return post.body();
}

相关文章

HttpRequest类方法