The Request.headers dictionary is not a documented interface. It should stay that way, because the complete set of headers are only accessible through the .get_header(), .has_header(), .header_items() interface. However, .headers pre-dates those methods, and so rea
(self)
| 87 | class RequestHdrsTests(unittest.TestCase): |
| 88 | |
| 89 | def test_request_headers_dict(self): |
| 90 | """ |
| 91 | The Request.headers dictionary is not a documented interface. It |
| 92 | should stay that way, because the complete set of headers are only |
| 93 | accessible through the .get_header(), .has_header(), .header_items() |
| 94 | interface. However, .headers pre-dates those methods, and so real code |
| 95 | will be using the dictionary. |
| 96 | |
| 97 | The introduction in 2.4 of those methods was a mistake for the same |
| 98 | reason: code that previously saw all (urllib2 user)-provided headers in |
| 99 | .headers now sees only a subset. |
| 100 | |
| 101 | """ |
| 102 | url = "http://example.com" |
| 103 | self.assertEqual(Request(url, |
| 104 | headers={"Spam-eggs": "blah"} |
| 105 | ).headers["Spam-eggs"], "blah") |
| 106 | self.assertEqual(Request(url, |
| 107 | headers={"spam-EggS": "blah"} |
| 108 | ).headers["Spam-eggs"], "blah") |
| 109 | |
| 110 | def test_request_headers_methods(self): |
| 111 | """ |
nothing calls this directly
no test coverage detected