[undertow-dev] Tracing HTTP Response content

Rohan Emmanuel rohan.emmanuel07 at gmail.com
Tue Feb 28 01:18:15 EST 2017


Thanks for suggestion.

To put it into simple terms ,what i am trying to do is,
a). I want to store all the response(headers+body) into cache,
     i.)if this is successful ,then begin writing the response to client.
     ii.)if store to cache fails, then write failure message(maybe 500
error message) to client.
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.

basically, i want to store the entire response to the cache before the
first byte is written on the socket.

Ultimately, The Cache will contain all the responses which are processed
successfully, which can be used for book-keeping.


Will StoredResponseStreamSinckConduit help me achieve the above?




On Tue, Feb 28, 2017 at 1:46 AM, Stuart Douglas <sdouglas at redhat.com> wrote:

> You can use the newish
> io.undertow.conduits.StoredResponseStreamSinkConduit, however you will
> need to be on a very recent version of Undertow (or you can just copy
> the code into your project).
>
> It won't be available in ResponseCommitListener though, as this is
> called before any content is written. To be honest I am not really
> sure what you are trying to do. In general if you can an IOException
> when writing the response there is nothing much you can do other than
> terminate the connection.
>
> Stuart
>
> On Tue, Feb 28, 2017 at 12:43 AM, Rohan Emmanuel
> <rohan.emmanuel07 at gmail.com> wrote:
> > Hi Stuart,
> >
> > i am new to Undertow code, Can you please elaborate.
> >
> > yes, The exchange will be passed to the ResponseCommitListener, but From
> > exchange i cannot get the response content directly ,correct? as there
> is no
> > method to get the Response body like getResponseHeaders.
> >
> > so i would need something like  a conduit inside my
> ResponseCommitListener
> > to get a handle on the response content?
> > Any other straight forward way to get the response content using exchange
> > object?
> >
> > Thanks for all the help.
> >
> >
> > On Mon, Feb 27, 2017 at 3:50 PM, Stuart Douglas <sdouglas at redhat.com>
> wrote:
> >>
> >> You have access to the exchange, it is passed into the
> >> ResponseCommitListener.
> >>
> >> Stuart
> >>
> >> On Mon, Feb 27, 2017 at 4:25 PM, Rohan Emmanuel
> >> <rohan.emmanuel07 at gmail.com> wrote:
> >> > hi Stuart,
> >> > I have a ResponseCommitListener added to my handler, I want this to
> >> > write to
> >> > the cache, so that my reponseWrapper will take of the error handling
> if
> >> > the
> >> > ResponsecommitListener faces any error while storing the response to
> >> > cache.
> >> >
> >> > I understand HttpResponseConduit constructs the headers and then
> pushes
> >> > the
> >> > response.
> >> > But the confusion is, how will i get a access to response Headers and
> >> > body
> >> > in the my ResponseCommitListener?
> >> >
> >> >
> >> > My approach is valid? if not ,any suggestion?
> >> >
> >> >
> >> > On Mon, Feb 27, 2017 at 8:03 AM, Stuart Douglas <sdouglas at redhat.com>
> >> > wrote:
> >> >>
> >> >> Whatever code is writing to the cache needs to just hold onto the
> >> >> exchange and send an error response as required.
> >> >>
> >> >> Stuart
> >> >>
> >> >> On Fri, Feb 24, 2017 at 5:31 PM, Rohan Emmanuel
> >> >> <rohan.emmanuel07 at gmail.com> wrote:
> >> >> > Hi,
> >> >> > i had a similar query, i want to store the entire response for my
> >> >> > book
> >> >> > keeping , before it is flush out on to socket connection.
> >> >> > if while storing the response(using a cache to store) any IO error
> >> >> > occurs ,
> >> >> > i want to send out 500 error instead.
> >> >> >
> >> >> > Any thoughts on how can this be achieved?
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Regards,
> >> >> > Rohan Emmanuel
> >> >> >
> >> >> > _______________________________________________
> >> >> > undertow-dev mailing list
> >> >> > undertow-dev at lists.jboss.org
> >> >> > https://lists.jboss.org/mailman/listinfo/undertow-dev
> >> >> _______________________________________________
> >> >> undertow-dev mailing list
> >> >> undertow-dev at lists.jboss.org
> >> >> https://lists.jboss.org/mailman/listinfo/undertow-dev
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > Regards,
> >> > Rohan Emmanuel
> >> _______________________________________________
> >> undertow-dev mailing list
> >> undertow-dev at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/undertow-dev
> >
> >
> >
> >
> > --
> > Regards,
> > Rohan Emmanuel
>



-- 
Regards,
Rohan Emmanuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20170228/f33be3a7/attachment.html 


More information about the undertow-dev mailing list