Re: [Resteasy-users] question about CORS
There is no good way to implement this in 2.3.x. You would have to write a resource class to handle all preflight OPTIONS requests. Depending on how you want to validate origins, you'd have to write a PreProcessInterceptor and PostProcessInterceptor and @Context inject a HttpResponse or HttpRequest respectively. FYI, 2.3.x is retired in the community and support and updates are only available by subscription. 3.0.x has been out for a year and can be installed on top of AS7 or EAP 6.x On 6/9/2014 11:50 AM, Gervasio Amy wrote: Hello all, I'm a RESTEasy 2.3.5 version user and I experiencing some issues while trying to enable CORS. I'm using this CORS filter implementation http://software.dzhuvinov.com/cors-filter.html (which is basically a servlet filter) and it works well for successful responses, but when I have to handle errors through ExceptionMapper, which returns a new response (for ex. Response.status(Response.Status.FORBIDDEN).build()) it removes the CORS headers previously set by the filter mentioned. I saw there a new CorsFilter https://github.com/resteasy/Resteasy/blob/70e918d9bbcd534ce177ae5b0a62b46408cf51e5/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/interceptors/CorsFilter.java created in 3.0.7 version, based on interceptors. So, my question is: how would I implement CORS in a application which uses previous version of RESTEasy? Thanks in advance, Gervasio -- HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing Easy Data Exploration http://www.hpccsystems.com ___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com -- HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing Easy Data Exploration http://p.sf.net/sfu/hpccsystems ___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users
Re: [Resteasy-users] Running ContainerWriteFilter *after* WriterInterceptor?
On 6/7/2014 5:51 PM, Heiko W.Rupp wrote: Hey Bill, thanks for your reply. Am 07.06.2014 um 22:08 schrieb Bill Burke bbu...@redhat.com: Unfortunately, the JAX-RS TCK expects that the MBW is not matched until after the WriterInterceptor is invoked. We used to match prior to What a c$%@! invoking the interceptor chain... Which makes so much sense So, you have 2 options: 1. In your WriterInterceptor buffer the json marshalling, change the content header, flush the buffer. I have this block in aroundWriteTo: try { context.proceed(); } finally { context.getHeaders().get(Content-Type).clear(); context.getHeaders().putSingle(Content-Type,APPLICATION_JAVASCRIPT); } But that header change is not recorded in the output. And when I understand you correctly above, this would be an issue anyway, because the changed header would influence the MBW matcher which runs after the interceptor. Headers get flushed and can't be changed after the entity has been written to the stream. Again, you'll have to buffer the entity and rewrite it to the actual stream after you've changed the content-type header. -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com -- HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing Easy Data Exploration http://p.sf.net/sfu/hpccsystems ___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users