-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Files limit v2 #203 #369
Files limit v2 #203 #369
Conversation
@fumieval I would love your feedback on the general design of this PR. |
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) |
Fixed, will need to upstream the generation of multipart form data to hspec-wai |
This PR was a real trek. @fumieval please take a look, thanks! |
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. |
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 untilfiles
,formParams
etc. is called.files
parses the form body and produce temp files, which are then read back into memory to preserve backward API compatibility.filesOpts
that offers a continuation for lexical scoping of the temp files, as well as options to limit request size parameters (number and size of files etc.). I think users should be nudged towards using this oneBREAKING CHANGES:
File
type has now a type parameter to reflect whether it carries file contents or just a filepath pointing to the temp file.NEW MODULE:Web/Scotty/Internal/WaiParseSafe.hs , which will be removed once add and use RequestParseException in Network.Wai.Parse yesodweb/wai#964 gets merged and published upstreamnow usingwai-extra-3.1.14
since Ocramz safe parserequestbodyex #963 yesodweb/wai#972TODO:
InvalidRequest
https://hackage.haskell.org/package/warp-3.3.31/docs/Network-Wai-Handler-Warp.html#t:InvalidRequest andRequestParseException
. I think these should be simply wrapped intoScottyException
and enrich the handler with new cases.filesOpts
from Scotty and .Transfiles
works for both URL-encoded andmultipart
form uploadsnext
(remember Request body is preserved across 'next' calls #147 #308 ?).closes #203 , closes #183 , closes #370