如何使用 Restlet 2.0 从 REST 服务器资源访问 GET 请求的正文?
我想从 REST 服务器资源(使用 Restlet 2.0)访问 GET 请求的正文。这有几个原因:
我想在 GET 请求中发送参数(以 JSON 格式),例如“返回具有这些字段/值的完整对象...”
我想使用以下方法来保护 URL 请求的参数https,如果我将它们指定为 url 参数,我将无法保护
我想避免很长的网址。
我还在阅读: HTTP GET with request body
我正在查看代码/示例和 api,但我没有找到解决方案,你能建议我一种方法吗?您看到更好的框架/解决方案吗? 谢谢 !!! 科西斯基
i would like to access the body of a GET request from a REST server resource (with restlet 2.0). This for a few reasons:
i would like to send parameters (in a JSON format) in the GET request, lets say for example "return the full object that has these fields/values ... "
i would like to protect the parameters of the URL request using https, and if i specify them as url parameters i cant protect them.
i would like to avoid very long urls.
i was also reading: HTTP GET with request body
i was looking in the code/examples and the api but i didn't find a solution, could you suggest me an approach? do you see a better framework/solution?
thanks !!!
kocisky
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不使用 POST?您已经放弃了通过在正文中包含条件来缓存响应的能力。那么使用 GET 有什么好处呢?
与发送 GET 主体相比,使用 POST 对 HTTP 规范的破坏程度要小一些。
Why not use POST? You already threw away the ability to cache responses by including the criteria in the body. So what benefit is there to using GET?
Using POST has to be less of a subversion of the HTTP spec than sending a GET body.
为了做你想做的事,你需要使用Restlet的Request和Client API。使用 ClientResource 类无法完成此操作。您可以在下面找到一些实现该功能的提示:
跟踪参数允许您查看使用内部 Restlet 连接器时实际发送的内容。
希望对你有帮助,
蒂埃里
In order to do what you want, you need to use the Request and Client API of Restlet. This can't be done using the ClientResource class. You can find below some hints to implement that:
The tracing parameter allows you seeing what is actually sent when using the internal Restlet connector.
Hope it'll help you,
Thierry