django / daphne

Django Channels HTTP/WebSocket server
BSD 3-Clause "New" or "Revised" License
2.32k stars 256 forks source link

Implement WebSocket Denial Response extension #486

Open daveisfera opened 9 months ago

daveisfera commented 9 months ago

The value for code is hard coded to 403 when close happens while connecting

Kludex commented 6 months ago

Daphne doesn't implement this: https://asgi.readthedocs.io/en/latest/extensions.html#websocket-denial-response.

daveisfera commented 6 months ago

Daphne doesn't implement this: https://asgi.readthedocs.io/en/latest/extensions.html#websocket-denial-response.

I'm not sure what this is supposed to mean. The description sounds like it works and I've tested the change in the linked PR and it works

carltongibson commented 6 months ago

OK, thanks for looking at it @Kludex.

@daveisfera I'm not sure what the problem here really is, or why/how the PR resolves it. Also there's no tests.

I think to progress it would help to step back and explain what the issue is. Then we can think about the appropriate response.

(Sorry if that seems a pain, but I'm slow sometimes, and I like to understand an issue before just merging a proposal. Thanks.)

Kludex commented 6 months ago

The OP wants to send a different status code if the connection is rejected. It can only be done with the WebSocket Denial Response extension.

carltongibson commented 6 months ago

Ok, so I can have a read.

@daveisfera fancy doing a fuller job here?

Kludex commented 6 months ago

If reference is needed, both Uvicorn and Hypercorn implement the extension.

daveisfera commented 6 months ago

Honestly, I've moved onto a different approach, so if you're not interested in resolving this issue, then you can just close this

carltongibson commented 6 months ago

Ok, thanks for the input. I'll have a read about the extension anyhow.