Esempio n. 1
0
	def __init__(self, s, ts):
		m = re.match(r'^(GET|POST|PUT|DELETE|TRACE|CONNECT|OPTIONS|HEAD) (\S{1,4096}) HTTP/(1.\d)\r\n', s)
		if not m:
			raise HTTP_NotHTTP
		self.method, self.fullpath, self.httpver = m.groups()
		headers, self.payload = spl(s, '\r\n\r\n')
		self.headers = dict1([h.split(': ', 1) for h in headers.split('\r\n')[1:]])
		self.path, self.fragment = spl(self.fullpath, '#')
		self.path, self.querystring = spl(self.path, '?')
		self.query = dict1([spl(s, '=')
			for s in re.split('&(?:amp;)?', self.querystring)]) \
				if self.querystring else {}
		self.host = self.headers.get('host', [''])[0]
		self.url = 'http://' + self.host + self.path
		self.fullurl = 'http://' + self.host + self.fullpath
		self.ts = ts
		self.resp = None
		self.key = None
Esempio n. 2
0
	def __init__(self, s, ts):
		m = re.match(r'^HTTP/(1.\d) (\d{3}) (?:[^\r\n]{1,64})\r\n', s)
		if not m:
			raise HTTP_NotHTTP
		self.httpver, self.code = m.groups()
		headers, self.payload = spl(s, '\r\n\r\n')
		self.headers = dict1([h.split(': ', 1) for h in headers.split('\r\n')[1:]])
		self.ts_start = ts
		self.ts_last = None
		self.size = len(s)
Esempio n. 3
0
	def each_cookie(self):
		cookies = self.cookies()
		if not cookies:
			return []
		kv = flatten(c.strip().split('&') for c in cookies.split(';'))
		return [spl(val, '=') for val in kv]