[Twisted-Python] twcgi duplicate Content-Type
Laurens Van Houtven
lvh at laurensvh.be
Fri Dec 31 18:13:06 MST 2010
I'm using twcgi to serve a Fossil repository through CGI (it's that or
xinetd). For some reason, Chrome wasn't rendering the CSS. Looking at
the HTTP response headers for the GET request for the CSS file, I saw
HTTP/1.1 200 OK
Date: Sat, 01 Jan 2011 00:14:58 GMT
Expires: Sat, 8 Jan 2011 00:14:58 GMT
Content-Type: text/css; charset=utf-8
I'm pretty sure duplicate Content-Type headers aren't supposed to happen.
After some digging, I'm convinced the Server, Date and the first
Content-Type are the default values set in t.w.server . Meanwhile,
twcgi  users self.request.responseHeaders.addRawHeader, so the
default header is never overwritten.
I'm pretty sure that's not supposed to happen, but I'm not sure what
the correct way to fix this is. Options:
1) Should a list of things that need setRawHeader be introduced?
2) Should setRawHeader be the default, and instead have a list of
things that need addRawHeader?
3) Should that twcgi code use request.setHeader instead, like the
I have a feeling it's the last option. but like I said, I'm not sure.
cheers and happy new year,
More information about the Twisted-Python