How to access HttpRequest
I need to generate the URL of a resource that the client will then load. Django provides the HttpRequest.build_absolute_uri function to achieve this, however it's not clear how to access the HttpRequest object from an AsyncWebsocketConsumer. Please could this be added to the documentation?
Hi, I’d like to work on improving the documentation for this and clarify how to generate absolute URLs from an AsyncWebsocketConsumer.
I’ll explore the current Channels API and propose a documentation update.
Please let me know if anyone else is already working on this or if there’s any guidance on where this should be documented. Thanks!
I already did this in my lib: https://github.com/huynguyengl99/chanx/blob/b4869e9334d5ecf848ca02460ed89bd747ddb30f/chanx/channels/utils/request.py
hope that could help you guy.
All the information you need is just in the scope. Server, path, etc.
You build what you need from there:
https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope