wsproto
wsproto copied to clipboard
feature request: implement `response()` method for `Request` event
Of three events that require "trivial" response, Request, CloseConnection, and Ping, two implement response(), but one, Request, does not. If it did had response() method that returns AcceptConnection(), event processing workflow could be simpler than it has to be now:
for event in ws.events():
if isinstance(event, (CloseConnection, Ping, Request)):
write_data += ws.send(event.response())
elif isinstance(event, TextMessage):
# meningful processing
but as it is in the version 1.0.0, we have to have an extra elif for the Request case, that always sends AcceptConnection().