Hi, yes you can do it. All you need to do is modify the request "before" the body handler is triggered. For example I've created the following unit test:
@Test
public void testFormURLEncodedPatchingHeader() throws Exception {
router.clear();
router.route()
.handler(ctx -> {
ctx
.request()
.headers().set("content-type", "application/x-www-form-urlencoded");
ctx.next();
});
router.route().handler(BodyHandler.create());
router.route()
.handler(rc -> {
MultiMap attrs = rc.request().formAttributes();
assertNotNull(attrs);
assertEquals(3, attrs.size());
assertEquals("junit-testUserAlias", attrs.get("origin"));
assertEquals("ad...@foo.bar", attrs.get("login"));
assertEquals("admin", attrs.get("pass word"));
rc.response().end();
});
testRequest(HttpMethod.POST, "/", req -> {
Buffer buffer = Buffer.buffer();
buffer.appendString("origin=junit-testUserAlias&login=admin%40foo.bar&pass+word=admin");
req.headers().set("content-length", String.valueOf(buffer.length()));
req.write(buffer);
}, 200, "OK", null);
}
As you can see from the bottom I'm requesting a form encoded request without the content type header.
Then from the top, the request will be enhanced with a content type header, passed to the body handler, which will properly parse it (note, if you remove the previous step the test fails as body handler will not process) and finally assert that the data is present in the last server handler.
Cheers,
Paulo