Skip to content

Commit

Permalink
Allow building with text-2.0
Browse files Browse the repository at this point in the history
For the most part, this is simply a matter of raising the upper version bounds
in the `.cabal` file. The max-size request test case in the test suite needed
to be adjusted, as it needs to pick a sufficiently large request such that it
takes multiple chunks to store it as a lazy Text value. With `text-2.0` or
later, the amount of ASCII characters that a single chunk can store is much
larger due to using UTF-8 encoding internally, so we must generate a larger
request to compensate.
  • Loading branch information
RyanGlScott committed Sep 7, 2022
1 parent c31a8e2 commit 3d56d73
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scotty.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Library
mtl >= 2.1.2 && < 2.4,
network >= 2.6.0.2 && < 3.2,
regex-compat >= 0.95.1 && < 0.96,
text >= 0.11.3.1 && < 1.3,
text >= 0.11.3.1 && < 2.1,
transformers >= 0.3.0.0 && < 0.7,
transformers-base >= 0.4.1 && < 0.5,
transformers-compat >= 0.4 && < 0.8,
Expand Down
2 changes: 1 addition & 1 deletion test/Web/ScottySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ spec = do
withApp (Scotty.setMaxRequestBodySize 1 >> Scotty.matchAny "/upload" (do status status200)) $ do
it "upload endpoint for max-size requests, status 413 if request is too big, 200 otherwise" $ do
request "POST" "/upload" [("Content-Type","multipart/form-data; boundary=--33")]
(TLE.encodeUtf8 . TL.pack . concat $ [show c | c <- ([1..1500]::[Integer])]) `shouldRespondWith` 413
(TLE.encodeUtf8 . TL.pack . concat $ [show c | c <- ([1..4500]::[Integer])]) `shouldRespondWith` 413
request "POST" "/upload" [("Content-Type","multipart/form-data; boundary=--33")]
(TLE.encodeUtf8 . TL.pack . concat $ [show c | c <- ([1..50]::[Integer])]) `shouldRespondWith` 200

Expand Down

1 comment on commit 3d56d73

@asheshambasta
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RyanGlScott
Why are we generating bytes like these and not just via BL.replicate size (c2w char) where size and char are our variables?

Please sign in to comment.