From fd68940dd765dab78cc2bf8e560c16bc57ddb6a6 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Mon, 8 May 2017 23:17:04 +0300 Subject: [PATCH] WEB-26787 Can't download d.ts file for paper --- .../platform-api/src/com/intellij/util/net/NetUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platform/platform-api/src/com/intellij/util/net/NetUtils.java b/platform/platform-api/src/com/intellij/util/net/NetUtils.java index e8e9405c42b8..db2819c8199f 100644 --- a/platform/platform-api/src/com/intellij/util/net/NetUtils.java +++ b/platform/platform-api/src/com/intellij/util/net/NetUtils.java @@ -205,6 +205,14 @@ public class NetUtils { } } } + if (gzipStream != null) { + // Amount of read bytes may have changed when 'inputStream.read(buffer)' returns -1 + // E.g. reading GZIP trailer doesn't produce inflated stream data. + bytesRead = gzipStream.getCompressedBytesRead(); + if (indicator != null && expectedContentLength > 0) { + indicator.setFraction((double)bytesRead / expectedContentLength); + } + } if (indicator != null) { indicator.checkCanceled();