Skip to content

Commit

Permalink
(#396) Fixed unwated behaviour of files and filesOpts while not uploa…
Browse files Browse the repository at this point in the history
…ding any file.
  • Loading branch information
tusharad committed Apr 29, 2024
1 parent 9e9c1b4 commit 20203be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Web/Scotty/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import qualified Data.ByteString.Lazy.Char8 as BL
import qualified GHC.Exception as E (throw)
import Network.Wai (Request(..), getRequestBodyChunk)
import qualified Network.Wai.Handler.Warp as Warp (InvalidRequest(..))
import qualified Network.Wai.Parse as W (File, Param, getRequestBodyType, tempFileBackEnd, RequestBodyType(..), sinkRequestBodyEx, RequestParseException(..), ParseRequestBodyOptions)
import qualified Network.Wai.Parse as W (File, Param, getRequestBodyType, tempFileBackEnd, RequestBodyType(..), sinkRequestBodyEx, RequestParseException(..), ParseRequestBodyOptions,FileInfo(..))
-- import UnliftIO (MonadUnliftIO(..))
import UnliftIO.Exception (Handler(..), catches, throwIO)

Expand Down Expand Up @@ -64,7 +64,10 @@ getFormParamsAndFilesAction istate prbo req bodyInfo opts = do
let
wholeBody = BL.toChunks bs
(formparams, fs) <- parseRequestBodyExBS istate prbo wholeBody (W.getRequestBodyType req) `catches` handleWaiParseSafeExceptions
return (convertBoth <$> formparams, convertKey <$> fs)
let
fs' = filter emptyFile fs
return (convertBoth <$> formparams, convertKey <$> fs')
where emptyFile (_,fInfo) = ("\"\"" /= (W.fileName fInfo))

-- | Wrap exceptions from upstream libraries into 'ScottyException'
handleWaiParseSafeExceptions :: MonadIO m => [Handler m a]
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
### Breaking changes
* Remove dependency on data-default class (#386). We have been exporting constants for default config values since 0.20, and this dependency was simply unnecessary.
* Remove re-export of `Network.Wai.Parse.ParseRequestBodyOptions` from `Web.Scotty` and `Web.Scotty.Trans`. This is a type from `wai-extra` so exporting it is unnecessary.

* (#396) Fixed unwated behaviour of `files` and `filesOpts` while not uploading any file.


## 0.22 [2024.03.09]
Expand Down

0 comments on commit 20203be

Please sign in to comment.