-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Tracking: Improvements to DefaultBodyLimit
#1409
Comments
I will take care of the second todo in the list. |
GET could have body According moz Sending body/payload in a GET request may cause some existing implementations to reject the request — while not prohibited by the specification, the semantics are undefined. It is better to just avoid sending payloads in GET requests. |
That means we're allowed to reject the request, which I think we should. |
Where is this special-casing happening? |
@jplatte ContentLengthLimit had checks for that here https://github.com/tokio-rs/axum/blob/0.5.x/axum/src/extract/content_length_limit.rs#L54 |
I'm afraid I still don't really understand what has to change, but maybe that's fine and you'll just do the PR to tick the first checkbox 😄 |
I think we should just drop the first item. I elaborated a bit in the top comment. So when #1461 is merged I think we'll be in a good place. I'll just close this for now. |
#1400 will remove
ContentLengthLimit
in favor ofDefaultBodyLimit
but there a few things missing onDefaultBodyLimit
for it to have feature parity withContentLengthLimit
:We should make sureEdit: I think we should drop this. Not really clear where to enforce this. InGET
,HEAD
, andOPTIONS
requests without a body are still accepted. This can be done by checking thecontent-length
and if that is not there applyhttp_body::Limited
. Then sinceGET
,HEAD
, andOPTIONS
doesn't have bodies we should never hit the limit. Will be nice if that works because it removes special casing of those methods.Router
,MethodRouter
, handlers, or extractors? Just checking inRouter
isn't enough sinceMethodRouter
can be used withoutRouter
, and we don't wanna duplicate the check everywhere. If its really important correctness-wise then hyper should check it.DefaultBodyLimit
has private APIs for actually enforcing the limit. This is used byBytes::from_request
. We should add a public API for that thatMultipart
, and other library developers, can use to get the same limiting the request of axum-core has. Could probably be a new method onRequestExt
but since that isn't inaxum-core
it might require some exposing it there as well. Or maybe we moveRequestExt
to axum-core and re-export it from axum.RequestBodyLimit
andDefaultBodyLimit
. The difference is thatDefaultBodyLimit
doesn't change the request body type inRouter<ReqBody>
(see Middleware that change the request body have poor usability #1110). Instead if applies the checks directly in the extractors themselves. Thus its more opt-in but easier to integrate, so its a trade-off which middleware one should use.The text was updated successfully, but these errors were encountered: