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.
As specified in the asgiref documentation: "websocket.accept" message can have "headers" section https://asgi.readthedocs.io/en/latest/specs/www.html#accept-send-event 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')] }) since the original accept() method implementation does not have headers parameter https://github.com/django/channels/blob/507cb54fcb36df63282dd19653ea743036e7d63c/channels/generic/websocket.py#L184 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 Host: localhost:8080 Connection: Upgrade Pragma: no-cache Cache-Control: no-cache User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36 Upgrade: websocket Origin: http://localhost:8200 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 Server: Daphne Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Accept: XXXXXXXXXXXXXXXXXXXXXXXXXXX= I am using manage.py runserver command. Major packages of my pip freeze are: aiohttp==3.6.2 aioredis==1.2.0 asgiref==3.2.9 async-timeout==3.0.1 asyncio==3.4.3 billiard==3.6.0.0 channels==2.4.0 channels-redis==2.4.0 daphne==2.3.0 Django==2.2 django-cors-headers==2.3.0 django-crequest==2018.5.11 gunicorn==19.9.0 pika==0.12.0 redis==3.2.1 tornado==5.1 Twisted==18.9.0 txaio==18.8.1 urllib3==1.24.1 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 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/00693eea-809b-495e-a0a7-b70792065d15o%40googlegroups.com.