Re: Enforcing HTTP accept header
Hi all, In addition to Ben's excellent reply, I would point that ServerResource subclasses can enforce the media types they accept using annotation parameters, such as: @Put(xml) public void store(Document doc){ ... } More details in the Javadocs or here: http://wiki.restlet.org/developers/172-restlet/226-restlet.html Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com Ben R Vesco a écrit : As in, enforce a particular value in it? Check here: http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/130-restlet.html which shows us we can get the value from the header by querying the ClientInfo object like this: request.getClientInfo().getAcceptedMediaTypes() Which will return a list of the media types that were sent in that header. What you do with that info is pretty application specific. Perhaps a Filter that verifies the value in the beforeHandle method and takes some action if the values are not favorable? That would be a way to enforce it on every request. You could also verify it per resource or some other solution. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2412760 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2413026
Re: Enforcing HTTP accept header
I guess the correct syntax would be: @Put(xml) public void store(Document doc) { ... } Same goes for @Get annotation. You can get a list of supported out-of-the-box extensions here http://www.restlet.org/documentation/2.0/jse/api/org/restlet/service/MetadataService.html#addCommonExtensions() And use the values there as (String) parameters to the annotations. On Fri, Oct 30, 2009 at 12:11 PM, Jerome Louvel jerome.lou...@noelios.com wrote: Hi all, In addition to Ben's excellent reply, I would point that ServerResource subclasses can enforce the media types they accept using annotation parameters, such as: @Put(xml) public void store(Document doc){ ... } More details in the Javadocs or here: http://wiki.restlet.org/developers/172-restlet/226-restlet.html Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com Ben R Vesco a écrit : As in, enforce a particular value in it? Check here: http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/130-restlet.html which shows us we can get the value from the header by querying the ClientInfo object like this: request.getClientInfo().getAcceptedMediaTypes() Which will return a list of the media types that were sent in that header. What you do with that info is pretty application specific. Perhaps a Filter that verifies the value in the beforeHandle method and takes some action if the values are not favorable? That would be a way to enforce it on every request. You could also verify it per resource or some other solution. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2412760 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2413026 -- Fabián Mandelbaum IS Engineer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2413035
Re: Enforcing HTTP accept header
As in, enforce a particular value in it? Check here: http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/130-restlet.html which shows us we can get the value from the header by querying the ClientInfo object like this: request.getClientInfo().getAcceptedMediaTypes() Which will return a list of the media types that were sent in that header. What you do with that info is pretty application specific. Perhaps a Filter that verifies the value in the beforeHandle method and takes some action if the values are not favorable? That would be a way to enforce it on every request. You could also verify it per resource or some other solution. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2412760