Restlet 如何处理 HTTP Accept 标头?
Restlet 框架应该处理自动内容协商; 但是,它似乎做得不正确。
当客户端发送带有带有值的 Accept 标头的 HTTP GET 请求时,Restlet 不会自动协商内容。
有谁知道如何处理 Accept 标头?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Restlet API 广泛支持“Accept”标头。 该信息通过
Request.getClientInfo().getAcceptedMediaTypes()
:List
现在,为了自动为您协商内容,Restlet 引擎需要了解有关可用变体的信息。 这是 Restlet 1.1 中 org.restlet.resource.Resource 类的用途,以及正在开发的 Restlet 2.0 版本中新的 org.restlet.resource.ServerResource 类。
在 Restlet 1.1 中,您创建 Resource 的子类,声明如下变体:
然后重写
represent(Variant)
方法,如下所示:谨致问候,
杰罗姆
PS:请使用我们的邮件列表来解决未来的问题并查看档案:
http://www.restlet.org/community/lists
The Restlet API has extensive support for the "Accept" header. The information is parsed and available via the
Request.getClientInfo().getAcceptedMediaTypes()
:List<Preference<MediaType>>
method.Now, in order to automatically negotiate content for you, the Restlet engine needs to have information about the available variants. This is the purpose
org.restlet.resource.Resource class
in Restlet 1.1 and the neworg.restlet.resource.ServerResource
class in the Restlet 2.0 version being developed.In Restlet 1.1, you create a subclass of Resource, declare variants like this:
Then override the
represent(Variant)
method like this:Best regards,
Jerome
PS: please use our mailing list for future questions and look in the archives:
http://www.restlet.org/community/lists