django / asgiref

ASGI specification and utilities
https://asgi.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
1.46k stars 207 forks source link

Question about backwards compatibility #397

Closed kristjanvalur closed 1 year ago

kristjanvalur commented 1 year ago

It isn't clear from reading the spec, but are extra fields in events allowed? For example, the headers field was added to websocket.accept in revision 2.1. Is an application allowed to set such headers, before first checking the spec_version from the scope ?

andrewgodwin commented 1 year ago

Yes, extra keys in events and the scope are generally permitted, much like in WSGI - the spec defines what values must be present, rather than the entire schema of the dictionary. ASGI specs will jump minor versions (e.g. 2.0 -> 2.1) when new fields are added like that, and major versions (e.g. 1.0 -> 2.0) when fields/keys are either removed or their meaning in changed in a backwards-incompatible way.