Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Zocca committed Jan 1, 2024
1 parent 72626b5 commit 6609842
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Web/Scotty/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ parseRequestBodyExBS istate o bl rty =

-- | Retrieve the entire body, using the cached chunks in the BodyInfo and reading any other
-- chunks if they still exist.
-- Mimic the previous behavior by throwing BodyPartiallyStreamed if the user has already
-- Mimic the previous behavior by throwing 'BodyPartiallyStreamed' if the user has already
-- started reading the body by chunks.
--
-- throw 'ScottyException' if request body too big
getBodyAction :: BodyInfo -> RouteOptions -> IO (BL.ByteString)
getBodyAction (BodyInfo readProgress chunkBufferVar getChunk) opts =
modifyMVar readProgress $ \index ->
Expand Down
7 changes: 6 additions & 1 deletion test/Web/ScottySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ spec = do
let
large = TLE.encodeUtf8 . TL.pack . concat $ [show c | c <- ([1..4500]::[Integer])]
smol = TLE.encodeUtf8 . TL.pack . concat $ [show c | c <- ([1..50]::[Integer])]
withApp (Scotty.setMaxRequestBodySize 1 >> Scotty.post "/upload" (do status status200)) $ do
withApp (do
Scotty.setMaxRequestBodySize 1
Scotty.post "/upload" $ do
_ <- files
status status200
) $ do
context "application/x-www-form-urlencoded" $ do
it "should return 200 OK if the request body size is below 1 KB" $ do
request "POST" "/upload" [("Content-Type","application/x-www-form-urlencoded")]
Expand Down

0 comments on commit 6609842

Please sign in to comment.