Reputation: 1131
I'm using Jersey to send HTTP POST requests like this:
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
form.add("body", "Here there is my text");
ClientResponse response = resource.queryParams(form).type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class);
When I put in body element, text that its length is 7999 or less - the response from the other side is ok
However, if I try with length of the text of more than 8000 the response from the other side is:
returned a response status of 400 Bad Request
I tried to submit the same call from CURL in command line, and it passes fine.
The response status is 400
Could it be something in Jersey/Tomcat configuration?
I tried to add to tomcat connector maxHttpHeaderSize="65536"
but it didn't help
Upvotes: 0
Views: 2985
Reputation: 161
Jersey sends the data in request header, so once header size exceeds then its send 400 Bad request for that
You can edit tomcat/conf/server.xml's HTTP/1.1 Connector entry, and add a maxHttpHeaderSize="65536" to increase from the default maximum of 8K or so, to 64K. I imagine that you could up this number as high as necessary, but 64K suffices for my needs at the moment and its working.
Connector port="8080" maxHttpHeaderSize="65536" protocol="HTTP/1.1" ...
Upvotes: 0
Reputation: 14317
Change also the Jersey command to be:
ClientResponse response = resource.type("application/x-www-form-urlencoded").post(ClientResponse.class, form);
Instead of the way that you sent it with query params.
Upvotes: 2