jodd.http.HttpResponse.contentEncoding()方法的使用及代码示例

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

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

HttpResponse.contentEncoding介绍

暂无

代码示例

代码示例来源:origin: oblac/jodd

/**
 * Unzips GZip-ed body content, removes the content-encoding header
 * and sets the new content-length value.
 */
public HttpResponse unzip() {
  String contentEncoding = contentEncoding();
  if (contentEncoding != null && contentEncoding().equals("gzip")) {
    if (body != null) {
      headerRemove(HEADER_CONTENT_ENCODING);
      try {
        ByteArrayInputStream in = new ByteArrayInputStream(body.getBytes(StringPool.ISO_8859_1));
        GZIPInputStream gzipInputStream = new GZIPInputStream(in);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        StreamUtil.copy(gzipInputStream, out);
        body(out.toString(StringPool.ISO_8859_1));
      } catch (IOException ioex) {
        throw new HttpException(ioex);
      }
    }
  }
  return this;
}

代码示例来源:origin: org.jodd/jodd-http

/**
 * Unzips GZip-ed body content, removes the content-encoding header
 * and sets the new content-length value.
 */
public HttpResponse unzip() {
  String contentEncoding = contentEncoding();
  if (contentEncoding != null && contentEncoding().equals("gzip")) {
    if (body != null) {
      headerRemove(HEADER_CONTENT_ENCODING);
      try {
        ByteArrayInputStream in = new ByteArrayInputStream(body.getBytes(StringPool.ISO_8859_1));
        GZIPInputStream gzipInputStream = new GZIPInputStream(in);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        StreamUtil.copy(gzipInputStream, out);
        body(out.toString(StringPool.ISO_8859_1));
      } catch (IOException ioex) {
        throw new HttpException(ioex);
      }
    }
  }
  return this;
}

相关文章