Opened 4 years ago

Closed 3 years ago

#9346 defect closed wontfix (wontfix)

twisted.web.http_headers.Headers mangles headers

Reported by: Nonisiuniis Owned by:
Priority: normal Milestone:
Component: web Keywords: http, header, mangle
Cc: Branch:


Headers object defaults to lowercase all headers and then they are reformatted later. However this mangles headers that need to follow specific formatting, i.e. SOAPAction

>>> from twisted.web.http_headers import Headers
>>> h = Headers({'SOAPAction': ['https://server/path/SomeAction']})
>>> h
Headers({b'soapaction': [b'https://server/path/SomeAction']})

Docs: The SOAPAction HTTP Header Field

Change History (1)

comment:1 Changed 3 years ago by Glyph

Resolution: wontfix
Status: newclosed

Thank you for your interest in improving Twisted! I don't think we're going to do this, however.

Despite the idiomatic casing in the specification, SOAPAction doesn't need to be formatted in a specific way. In HTTP/1.1, header field names are case insensitive: - if you're using software that doesn't honor this, it's violating the specs.

More than that though, in HTTP/2.0, header field names are required to be lowercase on the wire and there is no way to preserve their case, so doing this in http/1.1 is a good practice to ensure applications are ready for upgrading to newer, better protocols. So if your application requires specific casing now, it's definitely going to break at some point in the future.

If you wanted to add a feature for protocol debugging / fuzzing like preserveCaseUnderHTTP11, we might accept such a thing if it were nicely tested and documented, but it's not something I think the project should make a priority, so I'm going to close this ticket.

Note: See TracTickets for help on using tickets.