testRequestBodyWriteString(false, "UTF-16");
}
private void testRequestBodyWriteString(boolean chunked, String encoding) {
String body = TestUtils.randomUnicodeString(1000);
Buffer bodyBuff;
if (encoding == null) {
bodyBuff = Buffer.buffer(body);
} else {
bodyBuff = Buffer.buffer(body, encoding);
}
server.requestHandler(req -> {
req.bodyHandler(buff -> {
assertEquals(bodyBuff, buff);
testComplete();
});
});
server.listen(onSuccess(server -> {
HttpClientRequest req = client.request(HttpMethod.POST, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, noOpHandler());
if (chunked) {
req.setChunked(true);
} else {
req.headers().set("Content-Length", String.valueOf(bodyBuff.length()));
}
if (encoding == null) {
req.write(body);
} else {