feat: introduce Body Limit Middleware using stream#2103
Conversation
Co-authored-by: Ame_x <121654029+EdamAme-x@users.noreply.github.com>
|
Express has an effortless way to customize its body limit, defaulting to 100kb max. |
…2109) * fix(body-limit): fix typo * feat(body-limit): Replace `c.req.raw` with body limit middleware proxy * refactor(body-limit): we can trust content-length header * fix(body-limit): call controller.error instead of throwing an error * test(body-limit): add test for ReadableStream body * chore: denoify * refactor(middleware/body-limit): throw HTTPException instead of retuning c.text()
|
Hey @usualoma Could you review this merged code again? |
Do we need data called
|
|
Personally, I have the above opinion about the current specifications of |
|
(A few updated implementation examples) |
|
Thanks, @usualoma ! As for Unit, I think removing it might be a good idea. I agree with the following opinion.
|
|
All works are finished! @EdamAme-x If you are okay, I'll merge this PR to the "next" with you as a co-author! |
|
@yusukebe Thank you! |
|
You are right. Updated! |
|
Hi @EdamAme-x! Now, I'll merge this into the "next". Thanks a lot! |
|
Oops. Mistook. Merged into the main. Reverting. |
This is an implementation of the feature proposed in #2077 using stream.
How to use
Simply specify the maximum size.
Using stream
The problem discussed in #2077 that a body must be read at a time is solved by using stream.
c.req.bodyCacheIt uses
c.req.bodyCacheused by the Validator implementation. By setting the loaded ArrayBuffer toc.req.bodyCache.arrayBuffer, such asc.req.json()will use that cached body from then on.Author should do the followings, if applicable
yarn denoifyto generate files for Deno