users@jersey.java.net

Handling of mutiple mime types : How to know which mime type has been chosen ?

From: Raphaël Jolivet <raphael.jolivet_at_gmail.com>
Date: Fri, 3 Sep 2010 04:57:02 -0700 (PDT)

Hello,

I have written a Jersey REST web service which get and put stream of
numerical data over the cloud.
For now, the data is converted to CSV stream.

I have added a parser / writer to binary format, to speed up things and to
reduce the bandwidth usage.

So, for now, I have something like :

    @GET @Path(METHOD_GET_DATA)
    @RolesAllowed(ROLE_READ)
    @Produces({CSV_MIME_TYPE, MY_BINARY_MIME_TYPE})
    public StreamingOutput getData(...) {...};

and

    @POST @Path(METHOD_PUT_DATA)
    @RolesAllowed(ROLE_WRITE)
    @Consumes({CSV_MIME_TYPE, MY_BINARY_MIME_TYPE})
    public String putData(...) { ...}

How do I know which mime type has been "agreed" with the client ?
For the "putData" method, I guess I just need to get the
ServletRequest#getMimeType(), to know
what is the format of the inputstream.

But for the "getData", how do I know which mime type is accepted by the
client ?
Is there a convenience method to get the result of the "agreement" between
the server and the client : The first mime type supported by both ?

Thanks in advance,

Raphael


-- 
View this message in context: http://jersey.576304.n2.nabble.com/Handling-of-mutiple-mime-types-How-to-know-which-mime-type-has-been-chosen-tp5495061p5495061.html
Sent from the Jersey mailing list archive at Nabble.com.