users@jersey.java.net

[Jersey] Re: Access-Control-Allow-Origin

From: Rimi <svetloe_at_gmail.com>
Date: Sun, 27 Mar 2011 01:38:27 -0700 (PDT)

Hi,

Can you please explain what you mean by "we'd need to be able to do HTTP
OPTIONS "mixing" (there is already an open JAX-RS issue against this)"?


I am trying to set "Access-Control-Allow-Origin" and other headers and
return it from OPTIONS method. However, I don't see that this method is
invoked. Here is my code:

    @OPTIONS
    @Path("testme")
    public Response testt(@Context HttpServletResponse servlerResponse) {
        servlerResponse.addHeader("Allow-Control-Allow-Methods",
"POST,GET,OPTIONS");
        servlerResponse.addHeader("Access-Control-Allow-Credentials",
"true");
        servlerResponse.addHeader("Access-Control-Allow-Origin", "*");
        servlerResponse.addHeader("Access-Control-Allow-Headers",
"Content-Type,X-Requested-With");
        servlerResponse.addHeader("Access-Control-Max-Age", "60");
        return Response.ok().build();
    }

    @POST
    @Path("testme")
    public String testme(@Context HttpServletResponse servlerResponse) {
        servlerResponse.addHeader("Allow-Control-Allow-Methods",
"POST,GET,OPTIONS");
        servlerResponse.addHeader("Access-Control-Allow-Credentials",
"true");
        servlerResponse.addHeader("Access-Control-Allow-Origin", "*");
        servlerResponse.addHeader("Access-Control-Allow-Headers",
"Content-Type,X-Requested-With");
        servlerResponse.addHeader("Access-Control-Max-Age", "60");
        return "str";
    }


thank you

--
View this message in context: http://jersey.576304.n2.nabble.com/Access-Control-Allow-Origin-tp6060693p6211931.html
Sent from the Jersey mailing list archive at Nabble.com.