http-header: support __contains__ in Headers
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 15 Mar 2012 17:54:40 +0100
changeset 8313 386b6313de28
parent 8312 6c2119509fac
child 8314 cfd6ab461849
http-header: support __contains__ in Headers You can now use:: >>> 'expires" in headers True
web/http_headers.py
--- a/web/http_headers.py	Thu Mar 15 17:48:20 2012 +0100
+++ b/web/http_headers.py	Thu Mar 15 17:54:40 2012 +0100
@@ -1290,11 +1290,13 @@
             self._raw_headers[name] = r
         return r
 
-    def hasHeader(self, name):
+    def __contains__(self, name):
         """Does a header with the given name exist?"""
         name=name.lower()
         return self._raw_headers.has_key(name)
 
+    hasHeader = __contains__
+
     def getRawHeaders(self, name, default=None):
         """Returns a list of headers matching the given name as the raw string given."""