Skip to content
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

Provide a configuration property for configuring Jetty's max form keys #42448

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qingbozhang
Copy link

I encountered an issue in the project related to form submissions, where the number of keys exceeded Jetty's default limit of 1000. I found that there's no way to configure this parameter in the Spring Boot configuration file.

Although I achieved my goal by setting org.eclipse.jetty.server.Request.maxFormKeys, it doesn't feel like an ideal solution.
May I submit a PR to add this configuration option?

@pivotal-cla
Copy link

@qingbozhang Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@qingbozhang Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 25, 2024
@wilkinsona wilkinsona changed the title feat: add maxFormKeys for jetty Provide a configuration property for configuring Jetty's max form keys Sep 25, 2024
@qingbozhang
Copy link
Author

Hi I’d appreciate a review when you have a moment. Thanks!

@wilkinsona
Copy link
Member

We're a small team with many different priorities. Expecting a review within two days of opening a PR isn't realistic. Someone will review this when we have time. Thank you for your patience in the meantime.

@qingbozhang
Copy link
Author

OK, thank you

Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, please review the comments when time permits.

@@ -1148,6 +1148,11 @@ public static class Jetty {
*/
private DataSize maxHttpFormPostSize = DataSize.ofBytes(200000);

/**
* Maximum size of the form keys.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really a size, is it? How about "Maximum number of form keys."

@@ -1180,6 +1185,14 @@ public void setMaxHttpFormPostSize(DataSize maxHttpFormPostSize) {
this.maxHttpFormPostSize = maxHttpFormPostSize;
}

public int getMaxFormKeys() {
return maxFormKeys;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing this.

@@ -122,7 +127,7 @@ private void customizeIdleTimeout(ConfigurableJettyWebServerFactory factory, Dur
});
}

private void customizeMaxHttpFormPostSize(ConfigurableJettyWebServerFactory factory, int maxHttpFormPostSize) {
private void customizeServletContextHandler(ConfigurableJettyWebServerFactory factory, Consumer<ServletContextHandler> customFunc) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before your change this method adds a customizer that is very much specific to maxHttpFormPostSize. The private method is still named setHandlerMaxHttpFormPostSize so that should change so that it is more clear that the intent is to customize the ServletContextHandler.

.to((maxHttpFormPostSize) -> customizeMaxHttpFormPostSize(factory, maxHttpFormPostSize));
.to((maxHttpFormPostSize) -> customizeServletContextHandler(factory, contextHandler -> contextHandler.setMaxFormContentSize(maxHttpFormPostSize)));
map.from(properties::getMaxFormKeys)
.when(this::isPositive)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a copy/paste of the mapping above. I am not sure it applies equally for this property.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants