Skip to content

Commit

Permalink
null value in HttpRequest.sendJson and HttpRequest.sendJsonable shoul…
Browse files Browse the repository at this point in the history
…d be treated as json null - fixes #1436
  • Loading branch information
vietj committed Oct 25, 2019
1 parent 32f6a48 commit bbf0633
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Expand Up @@ -424,15 +424,15 @@ private void handleSendRequest() {
if (request.timeout > 0) {
req.setTimeout(request.timeout);
}
if (body != null) {
if (contentType != null) {
String prev = req.headers().get(HttpHeaders.CONTENT_TYPE);
if (prev == null) {
req.putHeader(HttpHeaders.CONTENT_TYPE, contentType);
} else {
contentType = prev;
}
if (contentType != null) {
String prev = req.headers().get(HttpHeaders.CONTENT_TYPE);
if (prev == null) {
req.putHeader(HttpHeaders.CONTENT_TYPE, contentType);
} else {
contentType = prev;
}
}
if (body != null || "application/json".equals(contentType)) {
if (body instanceof MultiMap) {
MultipartForm parts = MultipartForm.create();
MultiMap attributes = (MultiMap) body;
Expand Down
Expand Up @@ -305,6 +305,14 @@ public void testSendBufferBody() throws Exception {
testSendBody(body, (contentType, buff) -> assertEquals(body, buff));
}

@Test
public void testSendJsonNullBody() throws Exception {
testSendBody(null, (contentType, buff) -> {
assertEquals("application/json", contentType);
// assertEquals(body, buff.toJsonObject());
});
}

private void testSendBody(Object body, BiConsumer<String, Buffer> checker) throws Exception {
waitFor(2);
server.requestHandler(req -> req.bodyHandler(buff -> {
Expand Down

0 comments on commit bbf0633

Please sign in to comment.