Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def handle_response (self, stream_id, headers):
# to HTTP/1.1 header
jheaders = []
for k, v in headers:
k = k.decode ("utf8")
v = v.decode ("utf8")
if k == ":status":
jheaders.insert (0, "HTTP/2.0 " + v + " " + respcodes.get (int (v), "Undefined Error"))
else:
jheaders.append (k + ": " + v)
h = self.get_handler (stream_id)
if h:
h.collect_incoming_data ("\r\n".join (jheaders).encode ("utf8"))
h.found_terminator ()
# finally, make inactive on post, put request
self.asyncon.set_active (False)
def handle_close (self, code = 700, msg = ""):
if code == 0: msg = ""
self.errcode = code
if msg:
self.errmsg = msg
else:
self.errmsg = respcodes.get (code, "Undefined Error")
self.close ()