[ZCM] [ZC] 2320/ 1 Request "HTTPResponse setHeader lowercases keys but getHeader does not"
"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Thu, 03 May 2007 16:39:58 -0400
| Newsgroups | gmane.comp.web.zope.devel.collector-monitor |
|---|---|
| Message-ID | <[email protected]> |
Issue #2320 Update (Request) "HTTPResponse setHeader lowercases keys but getHeader does not"
Status Pending, Zope/bug medium
To followup, visit:
http://www.zope.org/Collectors/Zope/2320
==============================================================
= Request - Entry #1 by hannosch on May 3, 2007 4:39 pm
Uploaded: "httpresponse.patch"
- http://www.zope.org/Collectors/Zope/2320/httpresponse.patch/view
The setHeader method of the HTTPResponse automatically lowercases the keys, but the getHeader method doesn't. This leads to the following unexpected behaviour:
>>> response = HTTPResponse()
>>> response.setHeader('Content-Type', 'foo')
>>> response.getHeader('Content-Type')
None
>>> response.getHeader('content-type')
'foo'
The attached patch solves this issue by bringing the Zope2 HTTPResponse in-line with the one from Zope3 which provides the same automatic lowercasing on the getHeader method. The example then reads:
>>> response.setHeader('Content-Type', 'foo')
>>> response.getHeader('Content-Type')
'foo'
>>> response.getHeader('content-type')
'foo'
This has been found as most code in Zope3 (in this case zope.app.pagetemplate.viewpagetemplatefile) checks for "response.getHeader('Content-Type')" and overwrites the content type via setHeader if not found.
If nobody objects I will apply this patch to the 2.10 branch and the trunk.
==============================================================