----- Forwarded Message -----
From: KT Nabe <th_nabe(a)yahoo.com>
To: "undertow-dev(a)lists.jboss.org" <undertow-dev(a)lists.jboss.org>
Sent: Tuesday, December 26, 2017 5:34 AM
Subject: Idiomatic POST body handling
Hello,
Is there an idiomatic/preferred/recommended way to configure an httphandler in such a way
that it is invoked only after all of the request headers *and* body have been *both*
drained (read from socket) and parsed? Obviously would need a way to say, "parse
entity/body bytes as String".
I've inferred that standard http-handlers are only invoked after the http headers have
been drained and parsed, and that they are invoked on an io thread.Here's what
I've been doing in the default handler:
if (exchange.isInIOThread() dispatch(this)
else exchange.getRequestReceiver().receiveFullString(exchange -> .....)
But it's occurred to me that this is inefficient, since I'm (I think):IO Thread
-> dispatch -> Worker-Thread -> IO-Thread (to drain/parse body as String) ->
WorkerThread (receiveFullString callback)
Now the above works, but I don't think it's optimal
I do want the receiveFullString callback to execute in an worker thread (since it blocks),
this is why I included the initial dispatch call, basically I just want a handler lambda
to be:
if exchange.isInIOThread() assert body-has-been-fully-drained-and-parsed-as-string
dispatch(this)else: String body = exchange.getBodyAsString?? .....
I'm assuming exchange.getRequestReceiver().receiveFullString is *always*
asynchronous.What's the best way to do this, since it's such a common
pattern?Thanks
Show replies by date