scotty-web / scotty

Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp (Official Repository)
http://hackage.haskell.org/package/scotty
BSD 3-Clause "New" or "Revised" License
1.72k stars 134 forks source link

Files limit v2 #203 #369

Closed ocramz closed 6 months ago

ocramz commented 9 months ago

second attempt at #203

Summary: form bodies (both URL-encoded and Multipart) are only parsed if/when needed by the files/filesOpts/formParam(s) `function.

Previously, Web.Scotty.Route.mkEnv used to parse request bodies to extract form parameters and files. Now we just use it to configure a body parsing function. A the usage site, ActionT combinators that need to access files or form parameters do the actual traversal/parsing work. This also means that the size of the request body is not known until files, formParams etc. is called.

BREAKING CHANGES:

NEW MODULE:

TODO:

closes #203 , closes #183 , closes #370

ocramz commented 9 months ago

@fumieval I would love your feedback on the general design of this PR.

ocramz commented 9 months ago

I'm finding out that Flask (python web framework) has a similar internal design for mulipart form handling (dump into temp files and load those on demand)

ocramz commented 7 months ago

I think the new tests fail because I generate an incorrect 'multipart' form body. Zero files are parsed, without indication of what goes wrong. The plot thickens..

Fixed, will need to upstream the generation of multipart form data to hspec-wai

ocramz commented 7 months ago

This PR was a real trek. @fumieval please take a look, thanks!

ocramz commented 7 months ago

Hi @fumieval I would really like to move this patch forward. I think it's a decent design but need your feedback as you're the only other maintainer at the moment. If there's anything you'd like me to change, or need more time for the review, please let me know.