很想在 Blackberry 应用程序的 API 调用中获取和设置 cookie?
有人可以帮我在来自黑莓应用程序的http get 请求中获取/设置cookie 吗?
我能够通过迭代响应标头来获取 cookie。我不知道这是否是检索 cookie 的最佳做法。请指教。
Can anybody please, help me out in get/set cookie in http get request from a blackberry application ?
I was able to get the cookie by iterating through the response header. I don't know whether this is the best practice to retrieve the cookie. Please advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要从 Http 响应中读取 cookie,您几乎可以通过迭代标头进行操作。
要设置 cookie,您必须使用“Set-Cookie”标头并为 Http 请求定义 name=value。如果您不知道如何在 Blackberry 中设置 HttpRequest 标头,则必须使用
HttpConnection
对象的setRequestProperty
方法。在这里,方法调用将如下所示:
con.setRequestProperty ("Set-Cookie", "NAME=VALUE");
Iterating through the headers is pretty much all you can do to read cookies from an Http response.
To set the cookie, you have to use the "Set-Cookie" header and have name=value defined for the Http requests. If you don't know how to set headers for HttpRequests in Blackberry, you have to use the
setRequestProperty
method for anHttpConnection
object.Here, the method call would be something like this:
con.setRequestProperty ("Set-Cookie", "NAME=VALUE");