<div dir="ltr">Hello,<div>I&#39;m trying to parse the response using responseDataHandler() in the custom policy. In cases, if the response from API is of certain content, I would like the Apiman to consider as failure. But I don&#39;t find a way to throw policy failure from responseDataHandler(). And I cannot achieve this in doApply() as the ApiResponse object does not have &quot;content&quot; to parse. </div><div><br></div><div>Also, what I found is write(chunk) in the AbstractStream is called after doApply, so I cannot set any attributes in it to fetch it in doApply() and trigger doFailure().</div><div><br></div><div>For example, in below call, how to throw as policy failure after parsing the contents ? Or how can I access response content even before write() method.</div><div><br></div><div><br></div><div><b>URLRewritingPolicy.java</b><br></div><div><br></div><div><div>    @Override</div><div>    protected IReadWriteStream&lt;ApiResponse&gt; responseDataHandler(ApiResponse response,</div><div>            IPolicyContext context, URLRewritingConfig policyConfiguration) {</div><div>        if (policyConfiguration.isProcessResponseBody()) {</div><div>            return new URLRewritingStream(context.getComponent(IBufferFactoryComponent.class), response,</div><div>                    policyConfiguration.getFromRegex(), policyConfiguration.getToReplacement());</div><div>        } else {</div><div>            return null;</div><div>        }</div><div>    }</div></div><div><b><br></b></div><div><b>URLRewritingStream.java</b><br></div><div><br></div><div><div>    /**</div><div>     * @see io.apiman.gateway.engine.io.AbstractStream#write(io.apiman.gateway.engine.io.IApimanBuffer)</div><div>     */</div><div>    @Override</div><div>    public void write(IApimanBuffer chunk) {</div><div>        if (buffer == null) {</div><div>            buffer = bufferFactory.cloneBuffer(chunk);</div><div>        } else {</div><div>            buffer.append(chunk);</div><div>        }</div><div>        atEnd = false;</div><div>        processBuffer();</div><div>    }</div></div><div><br></div><div><br></div><div>Best regards</div><div>Balu</div></div>