How to pass a multipart body into a new (proxied) request?

Skip to first unread message

Stephen Young

Jun 6, 2022, 1:03:38 AMJun 6
to vert.x
We're building an application/service gateway that inspects an incoming request and then passes it on to the appropriate application - which then returns a response via the gateway.  It's basically a reverse proxy with a memory that inspects the body of the request on the way through.  

We've been using the standard BodyHandler.  We just pass through getBody() to the forward request.

It works fine for anything except a multipart POST.  Unfortunately BodyHandler takes empties the buffer and makes files for these.

What's the easiest way to disable BodyHandler's default behaviour and pass the multipart body through as bytes?

Bruno F

Jun 6, 2022, 8:44:54 AMJun 6
to vert.x
Thomas seem to have answered a similar question on Stack Overflow a few months ago:
Maybe it can help?

Stephen Young

Jun 6, 2022, 7:05:13 PMJun 6
to vert.x
Thanks for this Bruno.  I can't see an easy solution in there, but we've solved the problem anyway by modifying how the BodyHandler code decides to collect from the buffer.

                // was if (!isMultipart /* && !isUrlEncoded */) {
                if (!handleFileUploads) {
                    if (body == null) {

Perhaps the vertx team could add an appropriate flag in future versions of BodyHandler?
Reply all
Reply to author
0 new messages