Re: Inviting feedback on my proposed "ASGI" spec
Cory Benfield <[email protected]> Thu, 10 Mar 2016 09:59:15 +0000
| Newsgroups | gmane.comp.python.web |
|---|---|
| Message-ID | <[email protected]> |
--===============1770925507374262745== Content-Type: multipart/signed; boundary="Apple-Mail=_039E6795-FBF5-45D9-8A6A-2AC178544446"; protocol="application/pgp-signature"; micalg=pgp-sha256 --Apple-Mail=_039E6795-FBF5-45D9-8A6A-2AC178544446 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 10 Mar 2016, at 00:34, Andrew Godwin <[email protected]> wrote: >=20 > To that end, I did some work to make the underlying mechanism Django = Channels uses into more of a standard, which I have codenamed ASGI; = while initially I intended for it to be a Django documented API, as I've = gone further with the project I've come to believe it could be useful to = the Python community at large. >=20 Andrew, Thanks for this work! I=E2=80=99ve provided some proposed changes as = pull requests against the channels repository. I=E2=80=99ll ignore those = for the rest of the email: we can discuss them on GitHub. I also have a few more general notes. I didn=E2=80=99t make PRs for = these, mostly because they=E2=80=99re too =E2=80=9Cvague=E2=80=9D as = feedback goes to be concretely handled by me. First, your HTTP section has request headers serialized to a dict and = response headers serialized to a list of tuples. I=E2=80=99m not sure = how I feel about that asymmetry: it might be cleaner just to use = lists-of-tuples in both places and allow application frameworks to = handle translation to dictionary if they require it. Second, if it were me I=E2=80=99d remove the `status_text` field on the = `Response` object. Custom status text is a terrible misfeature = (especially as HTTP/2 doesn=E2=80=99t support it), and in 99% of cases = you=E2=80=99re just wasting data by repeatedly sending the default = phrase that the server already knows. Third, you=E2=80=99re currently sending header fields with unicode names = and byte string values. That=E2=80=99s understandable, but I wonder if = it=E2=80=99s worthwhile trying to limit the behaviour of compliant = servers in encoding/decoding those header fields. For example, you could = assert that the unicode header names will always use the Latin-1 codec = when encoding/decoding. This is mostly me being paranoid about poorly = written apps/servers issuing bad bytes onto the network. I should note = that RFC 7230 strictly limits header names to US-ASCII, but Latin-1 = would be the defensive choice against already-badly-written apps. Your section on server push is great, whoever wrote that is clearly a = genius. ;) You define web socket data frames with an incrementing counter from = zero, but also note that the maximum integer size is Python=E2=80=99s = sys.maxint (you actually aren=E2=80=99t that clear about it, which might = be a good idea). While this is *probably* not a problem, you may want to = note that really long running or active web socket connections are at = risk of exhausting the =E2=80=98order=E2=80=99 counter, and define a = behaviour if that happens. Otherwise, this is an interesting specification. I=E2=80=99m certainly = open to helping push it through the PEP process if you=E2=80=99d like = assistance with that. Cory --Apple-Mail=_039E6795-FBF5-45D9-8A6A-2AC178544446 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJW4UVzAAoJEHD+F/imQ+FbO/AQAKwNsWca5iGjBjI3JDahH1kw In1WR/zFrVXt3kaxrQltSv9yDJApvj9Gm5q3Nb1a8esvQbo977EfLcrePKB6HJ0Z PwtVVNgtzBxZ5dvvNSwHDKoyhADqoVDPxoJRQBZ3BmE7V43Al6IImvOxg3Hj9Y5w 5+jD9XTdIw2BYL31v0Mei8dIXn2Faczrb7Rnc5f/qxeAvX8CkBNRsMLa6CtLX7nK ItZFAkD9dZqLVM5tUFVJ7cUx5w97fX1895YNW0yKSHglHgpCj7uCB3HiD3nrkhG9 AYlRnf0b+x4Az9fy6J7SEZrw9YxBeNc1oEIQOY+OZX0zjGVYJhMvztZ+OrcVeFIw umjZo8HD33wqNn0BBCqfRji0773lzOWZDbKli9ZjGBRdmaS1rnXku0XDVBkt8Am2 ZTFUunMWpAMJPaMFWh+srKy3aCd7lIy0P5LfNfz7hoYoXL7GUImUHaeeUjfh821M euTESpgiD8OgG89GveJdks+f4RrPEn4NRURS0IzWDWfqgTgwMAxMrhDepHYAL92w MYJnfs9RWkWlB2ZEU4kbOaCcEhA/KDkI0Zl2G56YU4LSJrT3rejIVsL3K8Cb8A6a PmbAOj4m2Wv9yyPRsEXesqZls1+xPaiOWicDoXb4vm3q1fVFDa6HsIFsVrB+fUGr 0JdZG2I0ql5rrA/K4tlG =dbb7 -----END PGP SIGNATURE----- --Apple-Mail=_039E6795-FBF5-45D9-8A6A-2AC178544446-- --===============1770925507374262745== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Web-SIG mailing list [email protected] Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: https://mail.python.org/mailman/options/web-sig/gcpw-web-sig%40m.gmane.org --===============1770925507374262745==--