如何使用 Cherry Py 将 Get/Post 请求标头解码为元组?
好的。至少一位真正乐于助人的人告诉我,他相信从 CherryPy 中解码和解析 GET/POST 请求标头很容易。我去过这里: http://www.cherrypy.org/wiki/BuiltinTools# tools.decode 但它没有给你一个例子。有人可以指导我一个更有用的例子吗?
Ok. I've been told by at least one really helpful individual who believes that its easy to decode and parse a GET/POST request header from within CherryPy. I've been here: http://www.cherrypy.org/wiki/BuiltinTools#tools.decode but it doesn't give you an example. Can someone direct me to a more helpful example?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您的问题包含两个部分:
1)如何获取标头
cherrypy.request.headers是一个字典,您可以像任何其他字典一样提取信息
2)如何使用tools.decode中提供的解码/编码支持
这将允许您使用上面的编码集解码字符串。返回的字符串是unicode。将从字典中提取的信息传递给解码和编码函数,您应该能够使用它。
I guess there are two parts embedded to your question:
1) How to get the headers
cherrypy.request.headers is a dict, you can extract information like any other dictionary
2) How to use the decoding / encoding support provided in tools.decode
This will allow you to decode a string using above encoding set. The string returned is unicode. Pass the information you extract from the dictionary to your decoding and encoding functions and you should be able to use this.