Hi Claus,
I think you have found an issue. More details follow.
The following resource works correctly for me:
@Path("/helloworld")
public class HelloWorldResource {
@HEAD
@Produces({MediaType.TEXT_PLAIN, MediaType.TEXT_HTML})
public void head() {
System.out.println("XXXXXX HEAD");
}
// The Java method will process HTTP GET requests
@GET
// The Java method will produce content identified by the MIME
Media
// type "text/plain"
@Produces({MediaType.TEXT_PLAIN, MediaType.TEXT_HTML})
public String getClichedMessage() {
// Return some cliched textual content
return "Hello World";
}
}
But the following does not:
@Path("/helloworld")
public class HelloWorldResource {
@HEAD
@Produces({MediaType.TEXT_PLAIN, MediaType.TEXT_HTML})
public void head() {
System.out.println("XXXXXX HEAD");
}
// The Java method will process HTTP GET requests
@GET
// The Java method will produce content identified by the MIME
Media
// type "text/plain"
@Produces({MediaType.TEXT_PLAIN})
public String getClichedMessage() {
// Return some cliched textual content
return "Hello World";
}
}
The head method only gets called when the media type is "text.html"
I think there are two issues:
1) The automatic HEAD support is enabled for the GET method in the
above failing case.
We need to check if an explicit HEAD method is implemented and
then check the intersection
of the produced media types with the GET. An implicit HEAD
method is require for the non-intersecting set.
2) The automatic HEAD implementation should return a 204 and not a 200.
Could you log an issue?
Thanks,
Paul.
On Mar 19, 2009, at 8:41 AM, cn_at_cn-consult.dk wrote:
> Hi.
>
> After reading thr JAX-RS spec I had the impression that this:
>
> @HEAD
> @Produces({MediaType.TEXT_PLAIN, MediaType.TEXT_HTML})
> public void head() {
> }
>
> should ensure that all "head" requests with mediatype "text/plain" or
> "text/html" recieves an 204 respons.
>
> Jersey seems to diasagree. If i only specify one MediaType, like this:
>
> @HEAD
> @Produces(MediaType.TEXT_PLAIN)
> public void head() {
> }
>
> I do get an 204 response for "text/plain" head requests, but shouldn't
> @Produces support specifying more than one MediaType?
>
> Best regards
> Claus Nielsen
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>