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
I tried creating a middleware to handle CORS, and I think it would have worked fine in the case of regular Response()s where the handler hasn't called response.start(request).
My handler for Server-sent events (the whole reason I switched to aiohttp btw) however instantiates a StreamResponse object and calls start on it. The headers are flushed out and with the current API, middlewares have no opportunity to do their thing. Actually, they probably never will see the response object, as the client closes the connection before the handler coroutine finishes (in my case it just asyncio.sleeps for 12h).
I have many handlers creating regular Response()s, and for those the middleware solution would work just fine. It would however be nice to be able to rely on middlewares to take care of all requests and replies, without corner cases like now.
The text was updated successfully, but these errors were encountered:
Yes, you cannot change response headers for started response (read StreamResponse and WebSocketResponse).
It should be done by signals (not implemented yet, #401 )
I tried creating a middleware to handle CORS, and I think it would have worked fine in the case of regular Response()s where the handler hasn't called response.start(request).
My handler for Server-sent events (the whole reason I switched to aiohttp btw) however instantiates a StreamResponse object and calls start on it. The headers are flushed out and with the current API, middlewares have no opportunity to do their thing. Actually, they probably never will see the response object, as the client closes the connection before the handler coroutine finishes (in my case it just asyncio.sleeps for 12h).
I have many handlers creating regular Response()s, and for those the middleware solution would work just fine. It would however be nice to be able to rely on middlewares to take care of all requests and replies, without corner cases like now.
The text was updated successfully, but these errors were encountered: