本文整理汇总了Python中mimetools.Message.getheader方法的典型用法代码示例。如果您正苦于以下问题:Python Message.getheader方法的具体用法?Python Message.getheader怎么用?Python Message.getheader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mimetools.Message
的用法示例。
在下文中一共展示了Message.getheader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handshake
# 需要导入模块: from mimetools import Message [as 别名]
# 或者: from mimetools.Message import getheader [as 别名]
def handshake(self):
data = self.request.recv(1024)
headers = Message(StringIO(data.split("\r\n", 1)[1]))
body = data.split("\r\n\r\n")[1]
upgrade = headers.get("Upgrade", "")
if upgrade.lower() != "websocket":
print "WebSockets client " + self.client_address[0] + " wrong Upgrade"
return
if headers.getheader("Sec-WebSocket-Key") != None:
self.ws_rfc = True
response = self.handshake_singleKey(headers)
elif (headers.getheader("Sec-WebSocket-Key1") != None) and (headers.getheader("Sec-WebSocket-Key2") != None):
self.ws_rfc = False
response = self.handshake_twoKeys(headers, body)
else:
print "WebSockets client " + self.client_address[0] + " wrong structure"
return
self.handshake_done = self.request.sendall(response)
self.server.clients += [self]
print "WebSockets client " + self.client_address[0] + " handshaken"