在 Autobahn websocket 服务器的 ConnectionRequest.headers 中,所有 http header 键都以小写形式出现

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

为什么高速公路网络套接字服务器将所有 http header 键更改为小写?我需要使用带有自定义 header 'Authorization:Bearer $token' 的 OAuth2 标准在 header 中实现身份验证令牌。但似乎从高速公路 'request.headers' 在 WebSocketServerProtocol class 的 onConnect 方法中,所有键都更改为小写。这背后的原因是什么?在这种情况下,我可以使用 'authorization' 而不是 'Authorization' 作为从请求中获取身份验证令牌的密钥吗?

根据 HTTP RFC、"HTTP header ... field names are case-insensitive." 在您的示例中,以下任何传入的 header 拼写都是等效的:"Authorization"、"authorization"、"AuThOrIzAtIoN".

有问题的软件 lower-casifies header 使查找更容易。您应该始终使用 lower-case 版本作为密钥。