Search code examples
pythonwebsockettwistedautobahnautobahnws

All http header keys coming as lower case in ConnectionRequest.headers of Autobahn websocket server


Why does autobahn web socket server change all http header keys to lower case? I need to implement authentication token in header with OAuth2 standard with custom header 'Authorization:Bearer $token'. But it seems from autobahn 'request.headers' in onConnect method of WebSocketServerProtocol class all the keys are changed to lower case. What is the reason behind this? Can I use 'authorization' instead of 'Authorization' as the key to fetch auth token from request in this scenario?


Solution

  • According to the HTTP RFC, "HTTP header ... field names are case-insensitive." In your example, any of the following incoming header spellings are equivalent: "Authorization", "authorization", "AuThOrIzAtIoN".

    The software in question lower-casifies the header to make lookups easier. You should always use the lower-case version as the key.