users@jersey.java.net

[Jersey] Re: What is Jersey behavior when Content-Type is missing?

From: Christopher Currie <christopher_at_currie.com>
Date: Tue, 29 Nov 2011 11:11:25 -0800

On Tue, Nov 29, 2011 at 5:49 AM, Jan Algermissen
<jan.algermissen_at_nordsc.com> wrote:
> does anyone know what Jersey will do in terms of selecting a provider when Content-Type is missing in the (e.g. POST) request?

From the HTTP 1.0 spec:

'If and only if the media type is not given by a Content-Type header,
as is the case for Simple-Response messages, the recipient may attempt
to guess the media type via inspection of its content and/or the name
extension(s) of the URL used to identify the resource. If the media
type remains unknown, the recipient should treat it as type
"application/octet-stream".'

You're most likely to get "application/octet-stream", unless your
environment (servlet container, etc.) does some fancy content
inspection for you. If you want to do any content inspection yourself,
before your resource is invoked, you can implement a
ContainerRequestFilter.

HTH,
Christopher