def parse(self, data):
state = "init"
for line in data.splitlines():
if state == "init":
self.parseRequest(line)
state = "host"
continue
if state == "host":
match = re.match("host: (.*)$", line, re.IGNORECASE)
if match:
self.host = match.group(1)
state = "keys"
continue
if not line:
continue
line = line.split(":", 1)
if len(line) == 1:
raise SyntaxError("Unable to parse client header: %r" % line[0])
key, value = line
self.headers.append( (key, value) )
评论列表
文章目录