1

I have a rather bizarre question and could not find an answer anywhere. I am building a WSRequest request in Play! 2.4.3 and I am adding query params using setQueryParameter() to the request. after that, I send them to another server using request.get() and retrieving the result.

Everything works fine, but I am curious, what would happen if the parameters exceed the limit of the get(). Do I need to check this and make two individual requests? Is this handled somewhere or does it just return an exception?

Thanks

Petre Popescu
  • 1,950
  • 3
  • 24
  • 38

1 Answers1

1

I did not see this numbers in the documentation, but as I know - there is no limit to query string in the standards, so it's depend from the realisation. What is the maximum possible length of a query string?. I am pretty sure that another server can stuck in to the problem with long query string even before your server.

My only proposed solution is to check it by some simple code:

package controllers;

import javax.inject.Inject;

import play.*;
import play.mvc.*;

import play.libs.ws.*;
import play.libs.F.Promise;

public class Application extends Controller {

    @Inject WSClient ws;

    public Promise<Result> index() {
        WSRequest request = ws.url("http://httpbin.org/get");
        int paramsNumber = 100;
        for(int i=0; i<paramsNumber; i++){
          request.setQueryParameter("paramKey" + i, "paramValue" + i);
        }
        return request.get().map(response -> ok(response.getBody()));
    }

}

So, "http://httpbin.org/get" easily takes 100 params (and Play can create and send it of course). And with 1000 params it returns "414 Request-URI Too Large" but play still able to create and send 1000 params without error.

I am pretty sure that the question is not in the max param numbers but in the max query string length.

UPDATE

I run netcat echo locally - nc -l 8888 and then did request to the url http://127.0.0.1:8888 with 100000 parmeters, like &paramKey99999=paramValue99999 - it works like a charm. So I can answer: play 2.4.3 can send at least 100000 params in the the WS request totaly length of 2 600 000 chars. Are you sure you suppose to have more get parameters that this ?

Community
  • 1
  • 1
Andriy Kuba
  • 8,093
  • 2
  • 29
  • 46