[web] Add asserts to the raw header conversion functions
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 14 Mar 2014 11:11:28 +0100
changeset 9726 8905267dc7ae
parent 9725 2614362be11e
child 9727 33f6ad4c75a5
[web] Add asserts to the raw header conversion functions This API is terrible, but at least this might help us catch some errors in our conversion definitions.
web/http_headers.py
--- a/web/http_headers.py	Fri Mar 07 11:19:24 2014 +0100
+++ b/web/http_headers.py	Fri Mar 14 11:11:28 2014 +0100
@@ -1324,6 +1324,9 @@
         h = self._headers.get(name, None)
         r = self.handler.generate(name, h)
         if r is not None:
+            assert isinstance(r, list)
+            for v in r:
+                assert isinstance(v, str)
             self._raw_headers[name] = r
         return r
 
@@ -1362,6 +1365,9 @@
         Value should be a list of strings, each being one header of the
         given name.
         """
+        assert isinstance(value, list)
+        for v in value:
+            assert isinstance(v, str)
         name = name.lower()
         self._raw_headers[name] = value
         self._headers[name] = _RecalcNeeded