|
From: Gregor J. <gr...@ja...> - 2013-05-29 13:15:26
|
Hi Bill, no exceptions. Resteasy is overriding 201 with its 200 (void) - I stepped through it. As described below - resteasy ignores what http code the HttpResponse already has and just overrides it. It's happening here: org.jboss.resteasy.core.ServerResponseWriter In case the code of this class didn't change in the coming beta, I am pretty sure it not gonna change. Shall I raise a ticket for this? ----- Original Message ----- From: "Bill Burke" <bb...@re...> To: res...@li... Sent: Wednesday, May 29, 2013 2:37:33 PM Subject: Re: [Resteasy-developers] Fwd: Setting the response http code If you cannot override the status via the ContainerResponseContext.setStatus() then this is a bug. If Resteasy is overriding it, then there is some other exception happening after your ContainerResponseFilter that is changing the status. I'm releasing Beta-6 tomorrow. maybe your problems will go away. On 5/29/2013 5:12 AM, Gregor Jarisch wrote: > Hi, > > Looking at the code of resteasy - I figured out how the http status can be set. > In a ContainerResponseFilter the method filter has a ContainerResponseContext as on of its params. > At first I tried to set the status via setStatus() and getHttpResponse().setStatus - both don't work since resteasy overrides it at a later time. > > The solution I found is to override the http code of the JaxrsResponse (getJaxrsResponse().setStatus()) with the http code from the HttpResponse. > This is in fact the status resteasy going to use for overriding. > > > Although this does work - I think it would be nice if resteasy could do this for us in general. > Looking at the method org.jboss.resteasy.core.ServerResponseWriter#writeNomapResponse there could be a check whether the HttpResponse is anything else then 200 (or if it has been manually set [could be remembered in the HttpServletResponseWrapper]). > If so, resteasy should not override this value. > My suggestion includes the assumption that if the http code is different then 200 it was set by the developer (in one of the rest methods). > > Is there a scenario I am missing here or any other reason why this is not a good idea? > > - Gregor > > > ----- Forwarded Message ----- > From: "Gregor Jarisch" <gr...@ja...> > To: res...@li... > Sent: Tuesday, May 28, 2013 3:13:32 PM > Subject: [Resteasy-developers] Setting the response http code > > Hi there, > > something that is bugging me for quite some time since using resteasy is setting the http code in the response. > In my scenario I would like to create a resource by invoking a POST request. > After creating the resource I would like to return a 201 (created) to the client as well as a Location URI pointing to the newly created resource. > > I set the 201 by injecting the HttpResponse. Unfortunately, resteasy ignores my set value an puts a 204 (No Content) instead, since the POST method's return type is void. > > Back in 2.3.* I was able to achieve this by overriding the value set by resteasy in a PostProcessInterceptor. Since this is deprecated now - what other options do I have? > > I am aware that I could build the Response object and return it - but this is not a clean interface definition in my opinion, since one couldn't see what's coming back only by looking at the return value of the interface. > > Is there any way to set the http code without returning the Response object? > > Thanks, > Gregor > -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com ------------------------------------------------------------------------------ Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET Get 100% visibility into your production application - at no cost. Code-level diagnostics for performance bottlenecks with <2% overhead Download for free and get started troubleshooting in minutes. http://p.sf.net/sfu/appdyn_d2d_ap1 _______________________________________________ Resteasy-developers mailing list Res...@li... https://lists.sourceforge.net/lists/listinfo/resteasy-developers |