本文整理汇总了Python中mimetools.Message.keys方法的典型用法代码示例。如果您正苦于以下问题:Python Message.keys方法的具体用法?Python Message.keys怎么用?Python Message.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mimetools.Message
的用法示例。
在下文中一共展示了Message.keys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extract_http
# 需要导入模块: from mimetools import Message [as 别名]
# 或者: from mimetools.Message import keys [as 别名]
def extract_http(request_text, dict_filed):
request_line, headers_alone = request_text.split('\r\n', 1)
headers = Message(StringIO(headers_alone))
# print request_line
request_line = request_line.split(' ', 2)
# print request_line[0]
if request_line[0] in {'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'CONNECT'}:
dict_filed['tags']['action'] = request_line[0]
dict_filed['tags']['Domain'] = headers['host']
dict_filed['tags']['URL'] = headers['host'] + request_line[1]
# print request_line[1]
else:
dict_filed['tags']['result_code'] = request_line[1]
if 'user_agent' in headers.keys():
dict_filed['tags']['user_agent'] = headers['user_agent']
if 'referer' in headers.keys():
dict_filed['tags']['referer'] = headers['referer']
if 'content-type' in headers.keys():
dict_filed['tags']['content-type'] = headers['content-type']
if 'accept' in headers.keys():
dict_filed['tags']['content-type'] = headers['accept']
# print headers.keys()
# print dict_filed['URL']
"""