<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 6, 2017 at 6:02 AM, paroczizs . <span dir="ltr">&lt;<a href="mailto:paroczizs@gmail.com" target="_blank">paroczizs@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:&quot;courier new&quot;,monospace">Hi Undertow dev,</div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace">I would like to use the RequestBufferingHandler in our proxy application. I found the following in a privious post:</div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace">&quot;RequestBufferingHandler is a performance enhancing handler that is designed to be used for blocking requests, basically</div><div style="font-family:&quot;courier new&quot;,monospace">it allows you to fully read the request before the request gets dispatched to a (potentially limited) thread pool.&quot;</div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace">I have to do the following:</div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace">- read the full request body or first limit size of the body e.g max 1MB if larger there is no need for the whole body.</div><div style="font-family:&quot;courier new&quot;,monospace">- do some check on the body content</div><div style="font-family:&quot;courier new&quot;,monospace">- forward the whole request towards the business backend using a proxy handler if the check was successful</div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace">I use the Undertow with Wildfly, the RequestBufferingHandler cannot be configured in the standalone.xml the error refer an unimplemented constructor.</div></div></blockquote><div><br></div><div>It can, but you need to use the expression-filter and use &#39;buffer-request(10)&#39; (10 is the number of buffers, the number you want will depend on your buffer size).</div><div><br></div><div>That said I don&#39;t think you really want to use request buffering handler here, like it says in the javadoc it is intended to provide some performance enhancements in a specific situation.</div><div><br></div><div>Instead your should write a handler that:</div><div><br></div><div>- Reads all the bytes, up to your specified maximum amount (and I assume rejects if it is too large, which request buffering handler will not do)</div><div>- Performs your checks</div><div>- Use Connectors.ungetRequestBytes() and Connectors.resetRequestChannel to make the data availble to later handlers (basically just copy the buffering handler and adapt it to your needs). </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:&quot;courier new&quot;,monospace">I can clone the RequestBufferingHandler into an own class and I suppose it works but I am not able to access the bufferd bytes due to the attachment key belongs HttpServerExchange and the attachment key is package private so I cannot use it.</div><div style="font-family:&quot;courier new&quot;,monospace"><br></div></div></blockquote><div><br></div><div>You are not supposed to directly access that attachment, it to enable the exchange to re-read the bytes. If you want to perform verification either use a different attachment or do the verification directly in your handler.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:&quot;courier new&quot;,monospace"></div><div style="font-family:&quot;courier new&quot;,monospace">Some more detail:</div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace">- I also would like to log the full in/out contents with conduits. With this I got an error if the RequestBufferingHandler registered and fired before the handler that wants to add the conduits. The problem here that I need some info from the request in the log (request id / correlation id / etc.). I can create callbacks towards the own conduit but it is not clear for me how the conduits and the RequestBufferingHandler work together.</div></div></blockquote><div><br></div><div>Just attach all the data in your handle, and log from the attached buffered data, rather than using a conduit.</div><div><br></div><div>Stuart</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace">Any help is appreciated.</div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace">Regards, Zsolt</div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div style="font-family:&quot;courier new&quot;,monospace"><br></div><div id="m_-3186565349216403654gmail-m_6878925675556719771DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br> <table style="border-top:1px solid rgb(211,212,222)">
        <tbody><tr>
      <td style="width:55px;padding-top:18px"><a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width:46px;height:29px"></a></td>
                <td style="width:470px;padding-top:17px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Mentes a vírusoktól. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" style="color:rgb(68,83,234)" target="_blank">www.avast.com</a>                 </td>
        </tr>
</tbody></table>
<a href="#m_-3186565349216403654_m_6878925675556719771_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div></div>
<br>______________________________<wbr>_________________<br>
undertow-dev mailing list<br>
<a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/undertow-dev</a><br></blockquote></div><br></div></div>