ardielle / ardielle-tools

Apache License 2.0
18 stars 19 forks source link

@Produces application/json annotation on OPTIONS methods incompatible with latest Firefox CORS requests #78

Closed havetisyan closed 7 years ago

havetisyan commented 7 years ago

We're using OPTIONS http method for CORS requests. RDL generates the following resource for the command:

@OPTIONS
@Path("/user/{userName}/token")    
@Produces(MediaType.APPLICATION_JSON)
public UserToken optionsUserToken(...)

The latest Firefox when issuing the command, uses the following value for Accept header:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

When processing this, jetty uses it's OPTIONS handler since text/html is of higher quality and does not call our method.

Since there is body currently defined to be generated for OPTIONS method, the rdl generator should not include the @Produces(MediaType.APPLICATION_JSON) annotation.