def process_headers(self, headers): for name, value in headers: if not isinstance(name, string_types): raise TypeError('%r is not a string' % name) if HEADER_RE.search(name): raise InvalidHeaderName('%r' % name) if HEADER_VALUE_RE.search(value): raise InvalidHeader('%r' % value) value = str(value).strip() lname = name.lower().strip() if lname == "content-length": self.response_length = int(value) elif util.is_hoppish(name): if lname == "connection": # handle websocket if value.lower().strip() == "upgrade": self.upgrade = True elif lname == "upgrade": if value.lower().strip() == "websocket": self.headers.append((name.strip(), value)) # ignore hopbyhop headers continue self.headers.append((name.strip(), value))
def process_headers(self, headers): for name, value in headers: if not isinstance(name, str): raise TypeError('%r is not a string' % name) if HEADER_RE.search(name): raise InvalidHeaderName('%r' % name) if not isinstance(value, str): raise TypeError('%r is not a string' % value) if HEADER_VALUE_RE.search(value): raise InvalidHeader('%r' % value) value = value.strip() lname = name.lower().strip() if lname == "content-length": self.response_length = int(value) elif util.is_hoppish(name): if lname == "connection": # handle websocket if value.lower().strip() == "upgrade": self.upgrade = True elif lname == "upgrade": if value.lower().strip() == "websocket": self.headers.append((name.strip(), value)) # ignore hopbyhop headers continue self.headers.append((name.strip(), value))
def process_headers(self, headers): for name, value in headers: assert isinstance(name, basestring), "%r is not a string" % name lname = name.lower().strip() if lname == "content-length": self.clength = int(value) elif util.is_hoppish(name): if lname == "connection": # handle websocket if value.lower().strip() != "upgrade": continue else: # ignore hopbyhop headers continue self.headers.append((name.strip(), str(value).strip()))
def process_headers(self, headers): for name, value in headers: assert isinstance(name, basestring), "%r is not a string" % name if util.is_hoppish(name): lname = name.lower().strip() if lname == "transfer-encoding": if value.lower().strip() == "chunked": self.chunked = True elif lname == "connection": # handle websocket if value.lower().strip() != "upgrade": continue else: # ignore hopbyhop headers continue self.headers.append((name.strip(), str(value).strip()))
def process_headers(self, headers): # pragma: no cover for name, value in headers: assert isinstance(name, basestring), "%r is not a string" % name lname = name.lower().strip() if lname == "content-length": self.response_length = int(value) elif util.is_hoppish(name): if lname == "connection": # handle websocket if value.lower().strip() == "upgrade": self.upgrade = True elif lname == "upgrade" and value.lower().strip() == "websocket": self.headers.append((name.strip(), str(value).strip())) # ignore hopbyhop headers continue self.headers.append((name.strip(), str(value).strip()))
def process_headers(self, headers): for name, value in headers: assert isinstance(name, string_types), "%r is not a string" % name value = str(value).strip() lname = name.lower().strip() if lname == "content-length": self.response_length = int(value) elif util.is_hoppish(name): if lname == "connection": # handle websocket if value.lower().strip() == "upgrade": self.upgrade = True elif lname == "upgrade": if value.lower().strip() == "websocket": self.headers.append((name.strip(), value)) # ignore hopbyhop headers continue self.headers.append((name.strip(), value))
def __init__(self, req, status, headers): self.req = req self.version = req.SERVER_VERSION self.status = status self.chunked = False self.headers = [] self.headers_sent = False for name, value in headers: assert isinstance(name, basestring), "%r is not a string" % name if is_hoppish(name): lname = name.lower().strip() if lname == "transfer-encoding": if value.lower().strip() == "chunked": self.chunked = True elif lname == "connection": # handle websocket if value.lower().strip() != "upgrade": continue else: # ignore hopbyhop headers continue self.headers.append((name.strip(), str(value).strip()))