joshgontijo / rest-client

MIT License
21 stars 5 forks source link

[Bug]: Get request with default headers fails #91

Closed bitsal closed 5 years ago

bitsal commented 5 years ago

Version: 1.6.0

I create a client like this:

RestClient.builder()
      .defaultHeader("Content-Type", "application/json")
      .build()

and when I do a get request like this:

client.get(<url>)
    .asObject(Map)

It fails in ClientRequest:172 with NullPointerException due to request body is null for get request.

request.getBody().implicitContentType()

request.getBody() is null

Expected result: Body should be checked on null value.

bitsal commented 5 years ago

Workaround:

RestClient client = RestClient.builder().build();
client.get(<url>).asObject(Map)

and POST requests

client.post(<url>).body(<body>).contentType(<CT>).asObject(Map)
joshgontijo commented 5 years ago

Fixed in 0beefe580e0000b6508dc0a507e3914c6036538c as part of 1.7.0