Alpha 4 new java http client

Hi, I am playing around with the new java client introduced in alpha 4. I was wondering why in the performRequest method there are all these mandatory fields. I need to provide a Map with params, I need to provide at least one header. This feels a bit weird. Now I have to create a call like this:

    Response response = client.performRequest(
            "GET",
            "_cluster/health",
            new Hashtable<>(),
            null,
            new BasicHeader("test", "test"));

In this case it would be enough to do something like this:

    Response response = client.performRequest(
            "GET",
            "_cluster/health");

Is it expected that I send a specific Header with every request?

Hi Jettro,
we went this way to keep things simple and avoid having many different variants of the same method with all the possible combinations of arguments. But about headers, that is a vararg, which means that you can happily omit it. You do have to provide an empty map though and null for the body as follows, which I agree it is not that nice:

Response response = client.performRequest(
            "GET",
            "_cluster/health",
            Collections.emptyMap(),
            null);

We could make this better and add a shortcut with no body and no parameters for this common case. My initial worry was that then people may also ask for another method with body but no parameters, and another one with parameters but no body. That feels like too much.

Do you see what I mean?

Cheers
Luca

Yes I understand what you mean thanks, it just feels strange to provide a null :slight_smile:.

Thanks for explaining.

Would you mind opening an issue so we can discuss this? Otherwise I will do it on your behalf :wink:

No problem, here it is: