diff options
-rwxr-xr-x | Lib/test/test_wsgiref.py | 5 | ||||
-rw-r--r-- | Lib/wsgiref/headers.py | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py index cea3565..cfadfbd 100755 --- a/Lib/test/test_wsgiref.py +++ b/Lib/test/test_wsgiref.py @@ -426,15 +426,20 @@ class HeaderTests(TestCase): h[b"Foo"] = bytes(b"bar") self.assertEqual("bar", h.get("Foo")) + self.assertEqual("bar", h.get(b"Foo")) h.setdefault(b"Bar", b"foo") self.assertEqual("foo", h.get("Bar")) + self.assertEqual("foo", h.get(b"Bar")) h.add_header(b'content-disposition', b'attachment', filename=b'bud.gif') self.assertEqual('attachment; filename="bud.gif"', h.get("content-disposition")) + del h['content-disposition'] + self.assert_(b'content-disposition' not in h) + class ErrorHandler(BaseCGIHandler): """Simple handler subclass for testing BaseHandler""" diff --git a/Lib/wsgiref/headers.py b/Lib/wsgiref/headers.py index 83074af..4e0076c 100644 --- a/Lib/wsgiref/headers.py +++ b/Lib/wsgiref/headers.py @@ -73,7 +73,7 @@ class Headers: Does *not* raise an exception if the header is missing. """ - name = name.lower() + name = self._convert_string_type(name.lower()) self._headers[:] = [kv for kv in self._headers if kv[0].lower() != name] def __getitem__(self,name): @@ -104,13 +104,13 @@ class Headers: fields deleted and re-inserted are always appended to the header list. If no fields exist with the given name, returns an empty list. """ - name = name.lower() + name = self._convert_string_type(name.lower()) return [kv[1] for kv in self._headers if kv[0].lower()==name] def get(self,name,default=None): """Get the first header value for 'name', or return 'default'""" - name = name.lower() + name = self._convert_string_type(name.lower()) for k,v in self._headers: if k.lower()==name: return v |