From: Ron S. <rs...@re...> - 2015-05-14 01:38:55
|
Hi Ramesh, Ok, I see that @Path("utf8") @Produces("text/plain;charset=utf-8") @POST public String utf8() { System.out.println("TestResource.utf8()"); return "ok"; } ... @Test public void testAcceptNoUtf8() throws Exception { ClientRequest request = new ClientRequest("http://localhost:8081/utf8/"); request.accept("text/plain"); ClientResponse<?> response = request.post(); Assert.assertEquals(200, response.getStatus()); String entity = response.getEntity(String.class); System.out.println("result: " + entity); } results in > org.jboss.resteasy.spi.NotAcceptableException: RESTEASY001530: No > match for accept header whereas @Path("nocharset") @Produces("text/plain") @POST public String noCharset() { return "ok"; } ... @Test public void testAcceptUtf8No() throws Exception { ClientRequest request = new ClientRequest("http://localhost:8081/nocharset/"); request.accept("text/plain;charset=utf-8"); ClientResponse<?> response = request.post(); Assert.assertEquals(200, response.getStatus()); String entity = response.getEntity(String.class); System.out.println("result: " + entity); } works fine. The relevant code is @Override public boolean isCompatible(MediaType other) { boolean result; if (other == null) result = false; if (getType().equals(MEDIA_TYPE_WILDCARD) || other.getType().equals(MEDIA_TYPE_WILDCARD)) result = true; else if (getType().equalsIgnoreCase(other.getType()) && (getSubtype().equals(MEDIA_TYPE_WILDCARD) || other.getSubtype().equals(MEDIA_TYPE_WILDCARD))) result = true; else { if (getType().equalsIgnoreCase(other.getType()) && this.getSubtype().equalsIgnoreCase(other.getSubtype())) { if (getParameters() == null || getParameters().size() == 0) { result = true; } else { result = this.equals(other); } } else { result = false; } } return result; } in org.jboss.resteasy.util.WeightedMediaType in the resteasy-jaxrs module. Very interesting. Honestly, I'm not sure how to think about this. The JAX-RS 1.1 spec says "An implementation MUST NOT invoke a method whose effective value of @Produces does not match the request Accept header.", but I don't see where it ever actually defines "match". And Resteasy passes the TCK tests. Really, I'm not even sure what "match" SHOULD mean. We could get crazy and do full blown unification (http://en.wikipedia.org/wiki/Unification_%28computer_science%29). Ugh. Resource matching is a very fundamental notion in JAX-RS, and I wouldn't want to make any changes without being very careful. Any thoughts about how to interpret "match"? -Ron > public boolean isCompatible(MediaType other) > { > boolean result; > if (other == null) > result = false; > if (getType().equals(MEDIA_TYPE_WILDCARD) || > other.getType().equals(MEDIA_TYPE_WILDCARD)) > result = true; > else if (getType().equalsIgnoreCase(other.getType()) && > (getSubtype().equals(MEDIA_TYPE_WILDCARD) || > other.getSubtype().equals(MEDIA_TYPE_WILDCARD))) > result = true; > else > { > if (getType().equalsIgnoreCase(other.getType()) > && > this.getSubtype().equalsIgnoreCase(other.getSubtype())) > { > if (getParameters() == null || getParameters().size() == 0) > { > result = true; > } > else > { > result = this.equals(other); > } > } > else > { > result = false; > } > } > return result; > } On 05/12/2015 03:55 PM, Ramesh Reddy wrote: > We are using under EAP 6.3 (2.3.8) and EAP 6.4 (2.3.9 or 2.3.10) > > ------------------------------------------------------------------------ > > Meant to reply to list. > > Anyway, it looks like Resteasy 2.3.10.Final, more or less. > > -Ron > > > -------- Forwarded Message -------- > Subject: Re: [Resteasy-users] Question about Accepts Header > Date: Mon, 11 May 2015 21:19:24 -0400 > From: Ron Sigal <rs...@re...> > To: Ramesh Reddy <ra...@re...> > > > > Hi Ramesh, > > Which version of Resteasy are you using in Teiid? > > Thanks, > Ron > > On 05/11/2015 05:05 PM, Ramesh Reddy wrote: > > Hi, > > > > In Teiid we have used RestEasy to implement the OData layer. We are seeing an issue with "Accepts" header. It is described herehttps://issues.jboss.org/browse/TEIID-3471 see 2nd comment. Any pointers to resolve are appreciated. > > > > Thanks > > > > Ramesh.. > > > > ------------------------------------------------------------------------------ > > One dashboard for servers and applications across Physical-Virtual-Cloud > > Widest out-of-the-box monitoring support with 50+ applications > > Performance metrics, stats and reports that give you Actionable Insights > > Deep dive visibility with transaction tracing using APM Insight. > >http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > > _______________________________________________ > > Resteasy-users mailing list > >Res...@li... > >https://lists.sourceforge.net/lists/listinfo/resteasy-users > > > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across > Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable > Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Resteasy-users mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-users > > |