You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spec/RSGI.md
+8-2
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# RSGI Specification
2
2
3
-
**Version:** 1.4
3
+
**Version:** 1.5
4
4
5
5
## Abstract
6
6
@@ -165,10 +165,11 @@ And here are descriptions for the upper attributes:
165
165
166
166
#### HTTP protocol interface
167
167
168
-
HTTP protocol object implements two awaitable methods to receive the request body, and five different methods to send data, in particular:
168
+
HTTP protocol object implements two awaitable methods to receive the request body, five different methods to send data, and one awaitable method to wait for client disconnection, in particular:
169
169
170
170
-`__call__` to receive the entire body in `bytes` format
171
171
-`__aiter__` to receive the body in `bytes` chunks
172
+
-`client_disconnect` to watch for client disconnection
172
173
-`response_empty` to send back an empty response
173
174
-`response_str` to send back a response with a `str` body
174
175
-`response_bytes` to send back a response with `bytes` body
@@ -180,6 +181,7 @@ All the upper-mentioned response methods accepts an integer `status` parameter,
180
181
```
181
182
coroutine __call__() -> body
182
183
asynciterator __aiter__() -> body chunks
184
+
coroutine client_disconnect()
183
185
function response_empty(status, headers)
184
186
function response_str(status, headers, body)
185
187
function response_bytes(status, headers, body)
@@ -197,6 +199,10 @@ coroutine send_bytes(bytes)
197
199
coroutine send_str(str)
198
200
```
199
201
202
+
The `client_disconnect` method will return a future that resolve ones the client has disconnected.
203
+
204
+
> **Note:** as HTTP supports keep-alived connections, the lifecycle of the client connection might not be the same of the single request. This is why the RSGI specification doesn't imply `client_disconnect` should resolve in case a client sends multiple requests within the same connection, and thus the protocol delegates to the application the responsibility to cancel the disconnection watcher once the response is sent.
205
+
200
206
### Websocket protocol
201
207
202
208
WebSockets share some HTTP details - they have a path and headers - but also have more state. Again, most of that state is in the scope, which will live as long as the socket does.
0 commit comments