def call(self): result = dict() for header_name, value in self.environ.items(): if not re.match(VALUABLE_HEADERS, header_name, flags=re.X | re.I): continue formatted_name = HeadersFormat.call(header_name) result[formatted_name] = value return result
def ip_headers(self, value): if isinstance(value, list): self.__ip_headers = [HeadersFormat.call(v) for v in value] else: raise ConfigurationError
def denylisted(self, value): if value: self.__denylisted = [HeadersFormat.call(v) for v in value] else: self.__denylisted = []
def test_call_removes_http_and_capitalizes(self): self.assertEqual(HeadersFormat.call('HTTP_X_TEST'), 'X-Test')
def test_without_http(self): self.assertEqual(HeadersFormat.call('X_TEST'), 'X-Test')
def test_does_not_remove_http_if_there_is_no_divider(self): self.assertEqual(HeadersFormat.call('httpX_teST'), 'Httpx-Test')
def test_mixed_dividers(self): self.assertEqual(HeadersFormat.call('http-X_teST'), 'X-Test')