<div dir="ltr">Thanks for suggestion.<div><br></div><div>To put it into simple terms ,what i am trying to do is,</div><div>a). I want to store all the response(headers+body) into cache, </div><div>     i.)if this is successful ,then begin writing the response to client.</div><div>     ii.)if store to cache fails, then write failure message(maybe 500 error message) to client.</div><div>b.) if while writing the response(failure message or success actual response) to client there is an IO exception, then Undertow already has the mechanism of terminating the connection, which is fine.</div><div><br></div><div>basically, i want to store the entire response to the cache before the first byte is written on the socket.<br></div><div><br></div><div>Ultimately, The Cache will contain all the responses which are processed successfully, which can be used for book-keeping.</div><div><br></div><div><br></div><div>Will StoredResponseStreamSinckConduit help me achieve the above?</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 28, 2017 at 1:46 AM, Stuart Douglas <span dir="ltr">&lt;<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You can use the newish<br>
io.undertow.conduits.<wbr>StoredResponseStreamSinkCondui<wbr>t, however you will<br>
need to be on a very recent version of Undertow (or you can just copy<br>
the code into your project).<br>
<br>
It won&#39;t be available in ResponseCommitListener though, as this is<br>
called before any content is written. To be honest I am not really<br>
sure what you are trying to do. In general if you can an IOException<br>
when writing the response there is nothing much you can do other than<br>
terminate the connection.<br>
<span class="HOEnZb"><font color="#888888"><br>
Stuart<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Tue, Feb 28, 2017 at 12:43 AM, Rohan Emmanuel<br>
&lt;<a href="mailto:rohan.emmanuel07@gmail.com">rohan.emmanuel07@gmail.com</a>&gt; wrote:<br>
&gt; Hi Stuart,<br>
&gt;<br>
&gt; i am new to Undertow code, Can you please elaborate.<br>
&gt;<br>
&gt; yes, The exchange will be passed to the ResponseCommitListener, but From<br>
&gt; exchange i cannot get the response content directly ,correct? as there is no<br>
&gt; method to get the Response body like getResponseHeaders.<br>
&gt;<br>
&gt; so i would need something like  a conduit inside my ResponseCommitListener<br>
&gt; to get a handle on the response content?<br>
&gt; Any other straight forward way to get the response content using exchange<br>
&gt; object?<br>
&gt;<br>
&gt; Thanks for all the help.<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Feb 27, 2017 at 3:50 PM, Stuart Douglas &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; You have access to the exchange, it is passed into the<br>
&gt;&gt; ResponseCommitListener.<br>
&gt;&gt;<br>
&gt;&gt; Stuart<br>
&gt;&gt;<br>
&gt;&gt; On Mon, Feb 27, 2017 at 4:25 PM, Rohan Emmanuel<br>
&gt;&gt; &lt;<a href="mailto:rohan.emmanuel07@gmail.com">rohan.emmanuel07@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; hi Stuart,<br>
&gt;&gt; &gt; I have a ResponseCommitListener added to my handler, I want this to<br>
&gt;&gt; &gt; write to<br>
&gt;&gt; &gt; the cache, so that my reponseWrapper will take of the error handling if<br>
&gt;&gt; &gt; the<br>
&gt;&gt; &gt; ResponsecommitListener faces any error while storing the response to<br>
&gt;&gt; &gt; cache.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I understand HttpResponseConduit constructs the headers and then pushes<br>
&gt;&gt; &gt; the<br>
&gt;&gt; &gt; response.<br>
&gt;&gt; &gt; But the confusion is, how will i get a access to response Headers and<br>
&gt;&gt; &gt; body<br>
&gt;&gt; &gt; in the my ResponseCommitListener?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; My approach is valid? if not ,any suggestion?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Mon, Feb 27, 2017 at 8:03 AM, Stuart Douglas &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt;<br>
&gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Whatever code is writing to the cache needs to just hold onto the<br>
&gt;&gt; &gt;&gt; exchange and send an error response as required.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Stuart<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On Fri, Feb 24, 2017 at 5:31 PM, Rohan Emmanuel<br>
&gt;&gt; &gt;&gt; &lt;<a href="mailto:rohan.emmanuel07@gmail.com">rohan.emmanuel07@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt;&gt; &gt; i had a similar query, i want to store the entire response for my<br>
&gt;&gt; &gt;&gt; &gt; book<br>
&gt;&gt; &gt;&gt; &gt; keeping , before it is flush out on to socket connection.<br>
&gt;&gt; &gt;&gt; &gt; if while storing the response(using a cache to store) any IO error<br>
&gt;&gt; &gt;&gt; &gt; occurs ,<br>
&gt;&gt; &gt;&gt; &gt; i want to send out 500 error instead.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Any thoughts on how can this be achieved?<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; --<br>
&gt;&gt; &gt;&gt; &gt; Regards,<br>
&gt;&gt; &gt;&gt; &gt; Rohan Emmanuel<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; ______________________________<wbr>_________________<br>
&gt;&gt; &gt;&gt; &gt; undertow-dev mailing list<br>
&gt;&gt; &gt;&gt; &gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt; &gt; <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>
&gt;&gt; &gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; &gt;&gt; undertow-dev mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt; <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>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt; Regards,<br>
&gt;&gt; &gt; Rohan Emmanuel<br>
&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; undertow-dev mailing list<br>
&gt;&gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt;&gt; <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>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Regards,<br>
&gt; Rohan Emmanuel<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Regards,<br>Rohan Emmanuel</div></div>
</div>