From d4e258a1b6ba703fe988a4dede8d39be5674c002 Mon Sep 17 00:00:00 2001 From: Divam Date: Tue, 4 Jun 2024 20:53:58 +0900 Subject: [PATCH] Ignore content length checks when the stream is encoded --- lib/GHCup/Download/IOStreams.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/GHCup/Download/IOStreams.hs b/lib/GHCup/Download/IOStreams.hs index adc9f149..7d909ad1 100644 --- a/lib/GHCup/Download/IOStreams.hs +++ b/lib/GHCup/Download/IOStreams.hs @@ -123,11 +123,12 @@ downloadInternal = go (5 :: Int) downloadStream r i' = do void setup - let size = case getHeader r "Content-Length" of - Just x' -> case decimal $ decUTF8Safe x' of + -- We can only do content length checks & progress bar when the stream is not encoded + let size = case (getHeader r "Content-Length", getHeader r "Content-Encoding") of + (Just x', Nothing) -> case decimal $ decUTF8Safe x' of Left _ -> Nothing Right (r', _) -> Just r' - Nothing -> Nothing + _ -> Nothing forM_ size $ \s -> forM_ eCSize $ \es -> when (es /= s) $ throwIO (ContentLengthError Nothing (Just s) es) let size' = eCSize <|> size