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

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

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

HttpRequest.uncompress介绍

[英]Set whether or not the response body should be automatically uncompressed when read from.

This will only affect requests that have the 'Content-Encoding' response header set to 'gzip'.

This causes all receive methods to use a GZIPInputStream when applicable so that higher level streams and readers can read the data uncompressed.

Setting this option does not cause any request headers to be set automatically so #acceptGzipEncoding() should be used in conjunction with this setting to tell the server to gzip the response.
[中]设置从读取时是否应自动解压缩响应正文。
这只会影响将“Content Encoding”响应头设置为“gzip”的请求。
这会导致所有接收方法在适用时使用GZIPInputStream,以便更高级别的流和读取器可以读取未压缩的数据。
设置此选项不会导致自动设置任何请求头,因此#acceptgzipencode()应与此设置结合使用,以告知服务器对响应进行gzip处理。

代码示例

代码示例来源: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类方法