Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore content length checks when the stream is encoded #1077

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/GHCup/Download/IOStreams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,16 @@ 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
dfordivam marked this conversation as resolved.
Show resolved Hide resolved
let notEncoded = case mk <$> getHeader r "Content-Encoding" of
Nothing -> True
Just "identity" -> True
Just _ -> False
size = case (notEncoded, getHeader r "Content-Length") of
(True, Just x') -> 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
Expand Down
Loading