From: Arnaud Schoonjans Date: Mon, 15 Dec 2025 11:12:18 +0000 (+0100) Subject: Make sure that the in-operator on HTTPHeaders is case insensitive X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87a85bb4de18ab17c360f7cb530274202fd05d4c;p=thirdparty%2Ftornado.git Make sure that the in-operator on HTTPHeaders is case insensitive --- diff --git a/tornado/httputil.py b/tornado/httputil.py index 13a95d90..74dfb87f 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -345,7 +345,8 @@ class HTTPHeaders(StrMutableMapping): # in __getitem__ when it's not needed. if not isinstance(name, str): return False - return name in self._as_list + norm_name = _normalize_header(name) + return norm_name in self._as_list def __getitem__(self, name: str) -> str: header = _normalize_header(name) diff --git a/tornado/test/httputil_test.py b/tornado/test/httputil_test.py index 7fa528cd..9c7ee093 100644 --- a/tornado/test/httputil_test.py +++ b/tornado/test/httputil_test.py @@ -329,6 +329,9 @@ Foo: even sorted(list(headers.get_all())), [("Asdf", "qwer zxcv"), ("Foo", "bar baz"), ("Foo", "even more lines")], ) + # Verify case insensitivity in-operator + self.assertTrue("asdf" in headers) + self.assertTrue("Asdf" in headers) def test_continuation(self): data = "Foo: bar\r\n\tasdf"