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

maxFormContentSize Server attributes are not being used with Context #4311

Closed
TomaszGaweda opened this issue Nov 13, 2019 · 1 comment
Closed

Comments

@TomaszGaweda
Copy link

Hi,

I've upgraded maven-jetty-plugin from 9.4.19.v20190610 to the newest release, however sometimes my queries ended with HTTP 400.

I found out, that this version is the latest version that does not ignore org.eclipse.jetty.server.Request.maxFormContentSize attribute. Starting from 9.4.20.v20190813, this attribute is ignored.

My jetty.xml:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
	<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
		<Set name="requestHeaderSize">65536</Set>
	</New>
	<Call name="addConnector">
		<Arg>
			<New class="org.eclipse.jetty.server.ServerConnector">
				<Arg name="server"><Ref refid="Server" /></Arg>
				<Arg name="factories">
					<Array type="org.eclipse.jetty.server.ConnectionFactory">
						<Item>
							<New class="org.eclipse.jetty.server.HttpConnectionFactory">
								<Arg name="config"><Ref refid="httpConfig" /></Arg>
							</New>
						</Item>
					</Array>
				</Arg>
				<Set name="host"><SystemProperty name="jetty.http.host" /></Set>
				<Set name="port"><SystemProperty name="jetty.http.port" default="8888" /></Set>
			</New>
		</Arg>
	</Call>
	<Call name="setAttribute">
		<Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
		<Arg>104857600</Arg>
	</Call>
	<Call name="setAttribute">
		<Arg>org.eclipse.jetty.server.Request.maxFormKeys</Arg>
		<Arg>2000</Arg>
	</Call>
</Configure>

I suspect this PR to broke the behaviour: 2e2cde6

If it's intended change, then documentation should be changed to point out the breaking change.

@joakime
Copy link
Contributor

joakime commented Nov 13, 2019

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

That's the DTD for Jetty 7 and Jetty 8.

Use:

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_9_3.dtd">

The settings for "Max Form Content Size" belong to the Context (a deployed webapp).
This configurable setting also only applies to non-multipart form usages.
The "Max Form Content Size" value is also only enforced once one of the HttpServletRequest.getParameter*() methods are called.

If the Request is submitted with Content-Type: multipart/form-data then you have to use the Servlet specific javax.servlet.annotation.MultipartConfig (or equivalent WEB-INF/web.xml descriptor xml elements) to configure it.

The pasted jetty.xml is incomplete.
Why are you attempting to customizing the entire jetty.xml anyway?

If you just want to configure the requestHeaderSize, then set the jetty.httpConfig.requestHeaderSize property to the value you need.

Example:

[mybase]$ cat start.ini
--module=deploy
--module=http
jetty.httpConfig.requestHeaderSize=65536

The two attributes on Server [org.eclipse.jetty.server.Request.maxFormContentSize, and org.eclipse.jetty.server.Request.maxFormKeys] were for no-context usages of max form content and keys.

For context based ones, please use the Context specific options (this is the recommended technique).

Example:

[mybase]$ ls -la
total 16
drwxr-xr-x  3 joakim joakim 4096 Nov 13 12:53 ./
drwxr-xr-x 13 joakim joakim 4096 Nov 13 08:08 ../
-rw-r--r--  1 joakim joakim   31 Nov 13 12:53 start.ini
drwxr-xr-x  2 joakim joakim 4096 Nov 13 12:53 webapps/

[mybase]$ tree
.
├── start.ini
└── webapps
    ├── ROOT.war
    └── ROOT.xml

1 directory, 3 files
[mybase]$ cat start.ini 
--module=deploy
--module=http

[mybase]$ cat webapps/ROOT.xml 
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="root-webapp" class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/</Set>
  <Set name="war"><Property name="jetty.webapps" default="."/>/ROOT.war</Set>

  <Set name="maxFormContentSize">100200300</Set>
  <Set name="maxFormKeys">2000</Set>
</Configure>

If you still need server-wide settings, use the system properties instead.

[mybase]$ cat start.ini 
--module=deploy
--module=http

-Dorg.eclipse.jetty.server.Request.maxFormContentSize=111333555
-Dorg.eclipse.jetty.server.Request.maxFormKeys=3000

@joakime joakime changed the title [9.4x] maxFormContentSize is being ignored maxFormContentSize Server attributes are not being used with Context Nov 13, 2019
@joakime joakime closed this as completed Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants