[Twisted-web] Headers dictionary
exarkun at divmod.com
Wed Feb 21 08:38:14 CST 2007
On Wed, 21 Feb 2007 14:13:20 +0100, Jarek Zgoda <jarek.zgoda at gmail.com> wrote:
>Is it only me, or the field names in
>twisted.web.http.Request.received_headers (also returned by
>getAllHeaders()) are case-sensitive? The RFC states, that they should
>(http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2), but if
>I set "Accept" header in client code (such as using Python's own
>httplib.HTTPConnection), there's no "accept" key in this dictionary,
>as available in resource's render_XXX method.
>Am I supposed to write my own HTTP compatibility layer for
>twisted.web, or I just overlooked something obvious?
Can you provide an example which demonstrates the problem you're seeing? This
example seems to demonstrate that all headers are lower-cased:
from twisted.web.resource import Resource
from twisted.web.server import Site
from twisted.application.service import Application
from twisted.application.internet import TCPServer
def getChild(self, *a):
def render_GET(self, request):
application = Application('HTTP Test')
Hitting the server with Firefox results in a dictionary with an 'accept'
key, with that spelling, regardless of the case of the input.
More information about the Twisted-web