MCPcopy Create free account
hub / github.com/boy-hack/hack-requests / __init__

Method __init__

HackRequests/HackRequests.py:342–377  ·  view source on GitHub ↗
(self, rep, redirect, log, oldcookie='')

Source from the content-addressed store, hash-verified

340class response(object):
341
342 def __init__(self, rep, redirect, log, oldcookie=''):
343 self.rep = rep
344 self.status_code = self.rep.status # response code
345 self.url = redirect
346 self._content = b''
347
348 _header_dict = dict()
349 self.cookie = ""
350 for k, v in self.rep.getheaders():
351 _header_dict[k] = v
352 # handle cookie
353 if k == "Set-Cookie":
354 if ";" in v:
355 self.cookie += v.strip().split(";")[0] + "; "
356 else:
357 self.cookie = v.strip() + "; "
358
359 if oldcookie:
360 cookie_dict = self._cookie_update(oldcookie, self.cookie)
361 self.cookie = ""
362 for k, v in cookie_dict.items():
363 self.cookie += "{}={}; ".format(k, v)
364 self.cookie = self.cookie.rstrip("; ")
365 try:
366 self.cookies = extract_dict(self.cookie, "; ", "=")
367 except:
368 self.cookies = {}
369
370 self.headers = _header_dict
371 self.header = self.rep.msg # response header
372 self.log = log
373 charset = self.rep.msg.get('content-type', 'utf-8')
374 try:
375 self.charset = charset.split("charset=")[1]
376 except:
377 self.charset = "utf-8"
378
379 def content(self):
380 if self._content:

Callers

nothing calls this directly

Calls 2

_cookie_updateMethod · 0.95
extract_dictFunction · 0.85

Tested by

no test coverage detected