<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"><<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>></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'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>
<<a href="mailto:rohan.emmanuel07@gmail.com">rohan.emmanuel07@gmail.com</a>> wrote:<br>
> Hi Stuart,<br>
><br>
> i am new to Undertow code, Can you please elaborate.<br>
><br>
> yes, The exchange will be passed to the ResponseCommitListener, but From<br>
> exchange i cannot get the response content directly ,correct? as there is no<br>
> method to get the Response body like getResponseHeaders.<br>
><br>
> so i would need something like a conduit inside my ResponseCommitListener<br>
> to get a handle on the response content?<br>
> Any other straight forward way to get the response content using exchange<br>
> object?<br>
><br>
> Thanks for all the help.<br>
><br>
><br>
> On Mon, Feb 27, 2017 at 3:50 PM, Stuart Douglas <<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>> wrote:<br>
>><br>
>> You have access to the exchange, it is passed into the<br>
>> ResponseCommitListener.<br>
>><br>
>> Stuart<br>
>><br>
>> On Mon, Feb 27, 2017 at 4:25 PM, Rohan Emmanuel<br>
>> <<a href="mailto:rohan.emmanuel07@gmail.com">rohan.emmanuel07@gmail.com</a>> wrote:<br>
>> > hi Stuart,<br>
>> > I have a ResponseCommitListener added to my handler, I want this to<br>
>> > write to<br>
>> > the cache, so that my reponseWrapper will take of the error handling if<br>
>> > the<br>
>> > ResponsecommitListener faces any error while storing the response to<br>
>> > cache.<br>
>> ><br>
>> > I understand HttpResponseConduit constructs the headers and then pushes<br>
>> > the<br>
>> > response.<br>
>> > But the confusion is, how will i get a access to response Headers and<br>
>> > body<br>
>> > in the my ResponseCommitListener?<br>
>> ><br>
>> ><br>
>> > My approach is valid? if not ,any suggestion?<br>
>> ><br>
>> ><br>
>> > On Mon, Feb 27, 2017 at 8:03 AM, Stuart Douglas <<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Whatever code is writing to the cache needs to just hold onto the<br>
>> >> exchange and send an error response as required.<br>
>> >><br>
>> >> Stuart<br>
>> >><br>
>> >> On Fri, Feb 24, 2017 at 5:31 PM, Rohan Emmanuel<br>
>> >> <<a href="mailto:rohan.emmanuel07@gmail.com">rohan.emmanuel07@gmail.com</a>> wrote:<br>
>> >> > Hi,<br>
>> >> > i had a similar query, i want to store the entire response for my<br>
>> >> > book<br>
>> >> > keeping , before it is flush out on to socket connection.<br>
>> >> > if while storing the response(using a cache to store) any IO error<br>
>> >> > occurs ,<br>
>> >> > i want to send out 500 error instead.<br>
>> >> ><br>
>> >> > Any thoughts on how can this be achieved?<br>
>> >> ><br>
>> >> ><br>
>> >> > --<br>
>> >> > Regards,<br>
>> >> > Rohan Emmanuel<br>
>> >> ><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>
>> >> ______________________________<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>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > Regards,<br>
>> > Rohan Emmanuel<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>
><br>
><br>
><br>
><br>
> --<br>
> Regards,<br>
> 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>