mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-11-04 12:50:10 +00:00
fix: harden gzip decode and release 0.4.5
Avoid ZipException when Vert.x already decompressed gzip bodies, keep jackson-databind on the IDE classpath, and show a real build version instead of unknown. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -368,9 +368,12 @@ public abstract class PanBase implements IPanTool, Closeable {
|
||||
// 检查响应头中的Content-Encoding是否为gzip
|
||||
String contentEncoding = res.getHeader("Content-Encoding");
|
||||
try {
|
||||
if ("gzip".equalsIgnoreCase(contentEncoding)) {
|
||||
if ("gzip".equalsIgnoreCase(contentEncoding) && res.body() instanceof Buffer gzipBody
|
||||
&& gzipBody.length() >= 2
|
||||
&& (gzipBody.getByte(0) & 0xff) == 0x1f
|
||||
&& (gzipBody.getByte(1) & 0xff) == 0x8b) {
|
||||
// 如果是gzip压缩的响应体,解压(只解压一次,缓存结果)
|
||||
String decompressed = decompressGzip((Buffer) res.body());
|
||||
String decompressed = decompressGzip(gzipBody);
|
||||
return new JsonObject(decompressed);
|
||||
} else {
|
||||
return res.bodyAsJsonObject();
|
||||
|
||||
Reference in New Issue
Block a user