示例#1
0
    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
示例#2
0
 def ip_headers(self, value):
     if isinstance(value, list):
         self.__ip_headers = [HeadersFormat.call(v) for v in value]
     else:
         raise ConfigurationError
示例#3
0
 def denylisted(self, value):
     if value:
         self.__denylisted = [HeadersFormat.call(v) for v in value]
     else:
         self.__denylisted = []
示例#4
0
 def test_call_removes_http_and_capitalizes(self):
     self.assertEqual(HeadersFormat.call('HTTP_X_TEST'), 'X-Test')
示例#5
0
 def test_without_http(self):
     self.assertEqual(HeadersFormat.call('X_TEST'), 'X-Test')
示例#6
0
 def test_does_not_remove_http_if_there_is_no_divider(self):
     self.assertEqual(HeadersFormat.call('httpX_teST'), 'Httpx-Test')
示例#7
0
 def test_mixed_dividers(self):
     self.assertEqual(HeadersFormat.call('http-X_teST'), 'X-Test')