Wildfly 9: Undertow setup by programming [max-post-size] rather than modifying standalone.xml

4.3k Views Asked by At

I need to increase the max-post-size of my undertow configuration, because I got the following exception

java.io.IOException: UT000020: Connection terminated as request was larger than 10485760 
at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168) 

and I need post requests with larger payloads.

However, I know that I could adapt standalone.xml, but I was not able to figure successfully out, how I can do this by programming or at least in web.xml (I need to be able to put the change in the build artifact rather than in the server configuration).

Edit:
I use the post requests with jax-rs @Post methods. If it is possible to e.g. annotate a payload size per request, it would also be OK, since there are only few requests needing higher payload size enabled.

Can anybody point my to what I can do?
Thanks in advance!

2

There are 2 best solutions below

1
On

Open admin console click configuration click subsystem click on web/http- undertow click on http HTTP-server-> defual-server edit max-post-size

2
On

I don't think it's possible with an annotation. You'd have to change the max-post-size attribute on the listener. A change to the listener requires a reload which is why it's not possible from an annotation.

With CLI on the default http-listener the command would be:

/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-post-size, value=20971520)