Hi,
I want to add WebSocket extension support to my Django channels consumer class. As I know a list of accepted extensions should be included in the headers of the handshake response of the consumer. I tried adding the response headers, however browser does not get them. I am not sure whether its a bug, or I have done something wrong.
In my AsyncJsonWebsocketConsumer class I am accepting the connection with this code:
await self.base_send({
"type": "websocket.accept",
"subprotocol": None,
"headers": [(b'sec-websocket-extensions', b'permessage-deflate')]
})
With this implementation latest Chrome/Firefox does not receive "Sec-WebSocket-Extensions: permessage-deflate" headeres in the handshake response. For example, I provide request and response headers:
The request headers are:
GET ws://localhost:8080/ws/my_route/ HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36
Sec-WebSocket-Version: 13
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Sec-WebSocket-Key: XXXXXXXXXXXXXXXXXXXXXX==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
The response headers are:
HTTP/1.1 101 Switching Protocols
Sec-WebSocket-Accept: XXXXXXXXXXXXXXXXXXXXXXXXXXX=
I am using manage.py runserver command. Major packages of my pip freeze are:
django-cors-headers==2.3.0
django-crequest==2018.5.11
Maybe you could advice me how to find the reason why the response headers are ignored? Should I report this as a bug to channels/asgiref?
Best regards,
Albertas