|
From: Weinan L. <we...@re...> - 2012-10-29 12:25:46
|
Hi Ori, Maybe you could try to use Exception Mapper: http://docs.jboss.org/resteasy/docs/2.3.4.Final/userguide/html_single/#ExceptionHandling -- Weinan Li JBoss, Red Hat On Monday, October 29, 2012 at 5:22 PM, Ori Liel wrote: > Hi, > > I have a small problem I could use some help with. > > When a user POSTs a request with an empty body, he gets 400 Bad Request with "SAXParseException; Premature end of file..." (since POST expects body). I'd like to show a friendlier message in the response body, something like: "POST request may not have empty body". > > Question 1: I'm looking for an interception point that will enable me to check if the user POSTed a request with an empty body. > > I tried using MessageBodyReaderInterceptor, but it appears that I don't have access to the Request object from the MessageBodyReaderContext object (am I wrong?) Then I noticed that ClientExecutionInterceptor seems to fit my needs, and wrote an interceptor that implements it - but the flow never reached it. > > Question 2: What are resteasy client interceptors, and how are they invoked? > > I'll elaborate a bit on the second question. Basically I'm not clear who is the 'client'. I always thought of client as the browser (or 'curl') making the http request, and resteasy runs server-side and handles the requests. So what does 'client' interceptor mean? When is a client interceptor invoked, and where does it run? Can I see it when debugging the server? Sorry for the very open question, but I'm missing something fundamental here... > > Thanks, > > Ori. > > ------------------------------------------------------------------------------ > The Windows 8 Center - In partnership with Sourceforge > Your idea - your app - 30 days. > Get started! > http://windows8center.sourceforge.net/ > what-html-developers-need-to-know-about-coding-windows-8-metro-style-apps/ > _______________________________________________ > Resteasy-developers mailing list > Res...@li... (mailto:Res...@li...) > https://lists.sourceforge.net/lists/listinfo/resteasy-developers > > |