From 4ea7b26c652709c02912298c953a9ab3c4d39355 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Sun, 3 Jan 2016 09:48:08 +0000 Subject: [PATCH 1/2] Draft proposal for Server Push messages --- docs/asgi.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/asgi.rst b/docs/asgi.rst index 281f0da..a7eb44d 100644 --- a/docs/asgi.rst +++ b/docs/asgi.rst @@ -484,7 +484,7 @@ Channel: ``http.response.?`` Keys: -* ``status``: Integer HTTP status code. +* ``status``: Integer HTTP status code. * ``status_text``: Byte string HTTP reason-phrase, e.g. ``OK`` from ``200 OK``. Ignored for HTTP/2 clients. Optional, default should be based on ``status`` @@ -524,9 +524,16 @@ Keys: Server Push ''''''''''' -Send before any Response or Response Chunk. HTTP/2 only. +Must be sent before any Response or Response Chunk messages. -TODO +Channel: ``http.response.?`` + +Keys: + +* ``request``: A Request message. Both the ``body`` and ``body_channel`` fields + MUST be absent: bodies are not allowed on server-pushed requests. The + ``reply_channel`` set on this object will be used for all further messages + relating to the pushed response. WebSocket From 894041a3c02b28b9b7f9c95a480995b94d1c67a4 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Tue, 5 Jan 2016 11:41:57 +0000 Subject: [PATCH 2/2] New approach to server push. --- docs/asgi.rst | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/asgi.rst b/docs/asgi.rst index a7eb44d..7ac6560 100644 --- a/docs/asgi.rst +++ b/docs/asgi.rst @@ -526,14 +526,32 @@ Server Push Must be sent before any Response or Response Chunk messages. +When a server receives this message, it must treat the Request message in the +``request`` field of the Server Push as though it were a new HTTP request being +received from the network. A server may, if it chooses, apply all of its +internal logic to handling this request (e.g. the server may want to try to +satisfy the request from a cache). Regardless, if the server is unable to +satisfy the request itself it must create a new ``http.response.?`` channel for +the application to send the Response message on, fill that channel in on the +``reply_channel`` field of the message, and then send the Request back to the +application on the ``http.request`` channel. + +This approach limits the amount of knowledge the application has to have about +pushed responses: they essentially appear to the application like a normal HTTP +request, with the difference being that the application itself triggered the +request. + +If the remote peer does not support server push, either because it's not a +HTTP/2 peer or because SETTINGS_ENABLE_PUSH is set to 0, the server must do +nothing in response to this message. + Channel: ``http.response.?`` Keys: -* ``request``: A Request message. Both the ``body`` and ``body_channel`` fields - MUST be absent: bodies are not allowed on server-pushed requests. The - ``reply_channel`` set on this object will be used for all further messages - relating to the pushed response. +* ``request``: A Request message. The ``body``, ``body_channel``, and + ``reply_channel`` fields MUST be absent: bodies are not allowed on + server-pushed requests, and applications should not create reply channels. WebSocket