How to server HTTP/2 protocol with Django

The request.scope dict has keys ‘type’, ‘http_version’ and ‘scheme’ that you can use.

My test program shows that I get {'type': 'http', 'http_version': '2', 'scheme': 'https', ... as the values in that dict.

(See HTTP & WebSocket ASGI Message Format — ASGI 3.0 documentation for more details. Also see GitHub - django/daphne: Django Channels HTTP/WebSocket server)

Thank you for asking this question! I learned a lot researching it.

1 Like