[Apiman-user] Is it possible blocking request after request body parsing?

林 柏廷 btlin1025 at hotmail.com
Wed Apr 25 01:29:55 EDT 2018


Hi all,
I would like to customize a policy, which parses the request body and blocks the request in case.
in http://www.apiman.io/latest/developer-guide.html 4.2.1.2 IData policy, it describes:
The request or response body will not begin streaming before the corresponding doApply has been called, however, it is still possible to interrupt the conversation during the streaming phase by signalling doFailure or doError.
When I trace the transformation-policy source code, doApply() executes before getRequestDataHandler() which matches the description.
In doApply() I can blocks the request via chain.doFailure() however I have no idea how to interrupt/block request in getRequestDataHandler().
Besides, I found following mail group which is similar to my question.
Eric also points it's possible to parse the body before apply in request:

On Thu, Feb 2, 2017 at 10:31 PM, Eric Wittmann <
eric.wittmann at redhat.com> wrote:

 The bottom line here is that you cannot return a Policy Failure (or
 customize it) based on information in the response body.  The response is
 streamed from the back-end to the client, and at the time streaming begins,
 the response code and HTTP headers have already been sent.

 It sounds to me like you're asking for a feature where you can parse
 the response body *before* the policy's "apply" method is invoked.  we have
 such a feature for requests, but not for responses.  I suspect core changes
 to apiman would be required to enable that.  It seems like a reasonable
 request to me, as long as users of the feature understand the performance
 and memory requirements of enabling it.

 -Eric

Thanks for any comments in advance.
Kind Regards
BT

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/apiman-user/attachments/20180425/8c5f2f6b/attachment-0001.html 


More information about the Apiman-user mailing list