Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Limit max content size for post.

Thanks Joakim,

Just to confirm your suggestion. I added this line 

jettyServer.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", 2);

to the code before starting jetty server.  But I still see same behavior and it is not failing for larger content. 


On Thu, Nov 14, 2013 at 4:07 PM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
Looks like on Jetty 8.1.9.v20130131 ...

You need to make sure that the .setAttribute(String, Object) call passes in a java.lang.String for the key, and an int, or java.lang.Integer, (not a String or Object) for the value.
Not sure how you ensure that the right object type is used in Spring though.
Try that.

Or, if you are using internal jetty components (not servlet), then you can use the ContextHandler.setMaxFormContentSize(int) as well.


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Thu, Nov 14, 2013 at 12:37 PM, Rajasekar Elango <relango@xxxxxxxxxxxxxx> wrote:
We are using jetty version :  8.1.9.v20130131

Thanks,
Raja.


On Thu, Nov 14, 2013 at 2:29 PM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
Which version of Jetty? (be specific!)

--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Thu, Nov 14, 2013 at 12:21 PM, Rajasekar Elango <relango@xxxxxxxxxxxxxx> wrote:
Hi,

We would like to limit max size of json data can be posted using REST api. Based on this documentation http://www.eclipse.org/jetty/documentation/current/setting-form-size.html
I have set value of attribute "org.eclipse.jetty.server.Request.maxFormContentSize" to 2 (picked very small value for testing)  for jetty Server class using spring configuration.

Here is the code of spring configuration:

<bean id="jettyServer" class="org.eclipse.jetty.server.Server"
          destroy-method="stop">
   ..... 
</bean>

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject">
            <ref local="jettyServer"/>
        </property>
        <property name="targetMethod">
            <value>setAttribute</value>
        </property>
        <property name="arguments">
            <list>
                <value>org.eclipse.jetty.server.Request.maxFormContentSize</value>
                <value>2</value>
            </list>
        </property>
</bean>

Before starting the server, I also verified that attribute "org.eclipse.jetty.server.Request.maxFormContentSize" has the value "2" on jettyServer instance.

However, I can successfully post json data to REST api over 2 bytes and not getting any errors. 
Am I missing anything? What is right way to limit content size that jetty can accept and verify if it works?



--
Thanks,
Raja.

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users



_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users




--
Thanks,
Raja.

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users



_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users




--
Thanks,
Raja.

Back to the top