[docs]classHttpResponseAsgiBridge:# todo protocol HttpResponseBridge"""Implements the ability of sending our HttpResponse object over the asgi protocol. This is still early impl. and it will need to support streaming responses in the future."""
[docs]asyncdefsend(self):# set the headers as read onlyself.response._headers=CIMultiDictProxy(self.response._headers)# prepare headers for asgiheaders=tuple((ensure_bytes(k),ensure_bytes(v))fork,vinself.response.headers.items())# start the responseawaitself.asgi_send({"type":"http.response.start","status":self.response.status,"headers":headers,})# send the bodyawaitself.asgi_send({"type":"http.response.body","body":ensure_bytes(self.response.body),})