-
Notifications
You must be signed in to change notification settings - Fork 355
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
[Feature request] Configuration options for multipart requests (Jersey 3.1.x) #5570
Comments
I think all of this logic can be implemented in the application itself, by using stuff like https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/input/CountingInputStream.html, but I know that |
It makes sense. We'll try our best for 3.1.7. |
Each At that point, the bean validation could do similar stuff, we need to check the BV possibilities with an Interesting requirements, I am not aware of any similar coming for the ordinary requests. |
|
Thanks @jansupol. Are you saying that this should be the preferred way of implementing these limits in custom code? I agree that setting the max request body size solves quite a lot of issues already, because then there is at least a general limit in place. |
This is me thinking loud mostly, hoping someone chimes in. But yes, with the current Jersey, it can be solvable by the ReaderInterceptor. For the future, we can implement some interceptor that would wrap the stream into some byte counter which can throw 413. Or there could be some more generic listener with something like |
I can see how that would work, following the example on https://www.baeldung.com/jersey-filters-interceptors#1-implementing-a-readerinterceptor. In that interceptor, the inputstream can be wrapped (and bytes counted), according to given limits. |
The low-hanging fruit, to limit the number of parts in the multipart entity, is implemented by #5643. |
Following jakartaee/rest#418 (comment), this is a feature request to get some configuration options for multipart requests into Jersey (or maybe into the JAX-RS spec even where it would make sense).
Ideally there would be a way to set both generic options as well as endpoint specific options.
The endpoint specific settings could be configured via an annotation (Jersey specific or JAX-RS), while the generic options could follow the approach mentioned in jakartaee/rest#418 (comment).
The additional options would be:
If either of these limits would be exceeded, an exception should be thrown, which by default should return a HTTP 413 status code.
The annotation approach would be useful to override generic options, per endpoint. Imagine that some endpoints will have different requirements about part size or part count.
commons-fileupload
offers similar options, see https://commons.apache.org/proper/commons-fileupload/using.html.Let me know what you think @jansupol. Thanks!
The text was updated successfully, but these errors were encountered: