From 078381c6dcdff7a7237e2f9a163456fc7add505d Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Tue, 7 Jan 2020 14:34:34 -0700 Subject: [PATCH] manually set content length --- src/Handler/Apps.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Handler/Apps.hs b/src/Handler/Apps.hs index bc17f55..2da2526 100644 --- a/src/Handler/Apps.hs +++ b/src/Handler/Apps.hs @@ -24,6 +24,7 @@ import Lib.Registry import Lib.Semver import Lib.Types.Semver import System.FilePath ((<.>)) +import System.Posix.Files (fileSize, getFileStatus) pureLog :: Show a => a -> Handler a pureLog = liftA2 (*>) ($logInfo . show) pure @@ -58,7 +59,10 @@ getApp rootDir ext = do Just (RegisteredAppVersion (_, filePath)) -> do exists <- liftIO $ doesFileExist filePath if exists - then respondSource typePlain $ CB.sourceFile filePath .| awaitForever sendChunkBS + then do + sz <- liftIO $ fileSize <$> getFileStatus filePath + addHeader "Content-Length" (show sz) + respondSource typePlain $ CB.sourceFile filePath .| awaitForever sendChunkBS else notFound