1

I am using JAX-RS to provide a server to process HTTP POST method in a Maven and Java project. The POST body is empty, they put the parameters in the URL, like:

http://IP:PORT/url?source=aaa&xml=*********

I use the following method to gain the two parameters:

(@QueryParam("source") String source, @QueryParam("xml") String xml)

If the XML is under 4 KB, it works well. But if the XML is larger than 4KB, I get the XML as null.

dur
  • 15,689
  • 25
  • 79
  • 125
yue.yang
  • 19
  • 3
  • add something , I can't put the xml in post body . we must put it in the url , this is the other company's Requirement – yue.yang Oct 31 '16 at 06:48
  • There is a limitation on the size of an url. Look at this : http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers – Ortomala Lokni Oct 31 '16 at 22:27
  • Tell them that the requirement should be changed, because it can't possibly work, technically. Just like if they asked for a car with square wheels. – JB Nizet Oct 31 '16 at 22:30

1 Answers1

0

I find it's not the limit of jax-rs . It's limited by jetty. I modified the dubbox in it's JettyHttpServer.class.

public static final String JETTY_HEADERBUFFERSIZE = "dubbo.jetty.headerBufferSize";
public static final String JETTY_REQUESTBUFFERSIZE = "dubbo.jetty.requestBufferSize";
public static final String JETTY_RESPONSEBUFFERSIZE = "dubbo.jetty.responseBufferSize";
     /**
         * you can set this values by -D when you start jvm
         * for example : -Ddubbo.jetty.headerBufferSize=32768  ( 32 * 1024 = 32768)
         * default values:
         * _headerBufferSize=4*1024;
         * _requestBufferSize=8*1024;
         * _responseBufferSize=24*1024;
         */
 SelectChannelConnector connector = new SelectChannelConnector();
        String headerBufferSize = System.getProperty(JETTY_HEADERBUFFERSIZE);
                if (headerBufferSize!=null && !headerBufferSize.isEmpty()){
                    logger.info("YOU CONFIGED THE JETTY_HEADERBUFFERSIZE:"+headerBufferSize);
                    connector.setHeaderBufferSize(Integer.parseInt(headerBufferSize));
                }
                String requestBufferSize = System.getProperty(JETTY_REQUESTBUFFERSIZE);
                if (requestBufferSize!=null && !requestBufferSize.isEmpty()){
                    logger.info("YOU CONFIGED THE JETTY_REQUESTBUFFERSIZE:"+requestBufferSize);
                    connector.setRequestBufferSize(Integer.parseInt(requestBufferSize));
                }
                String responseBufferSize = System.getProperty(JETTY_RESPONSEBUFFERSIZE);
                if (responseBufferSize!=null && !responseBufferSize.isEmpty()){
                    logger.info("YOU CONFIGED THE JETTY_RESPONSEBUFFERSIZE:"+responseBufferSize);
                    connector.setResponseBufferSize(Integer.parseInt(responseBufferSize));
                }

     server = new Server();
     server.addConnector(connector);

if you only use jetty or tomcat, you can also config the params by xml or code;

yue.yang
  • 19
  • 3