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
Describe the bug
When trying to use Request Streaming in a route that is part of a blueprint, the request.stream object is never set (it is None), unlessstream=True has been set on some global route.
Code snippet
from sanic import Sanic
from sanic.response import text
from sanic.views import HTTPMethodView, stream
from sanic import Blueprint
app = Sanic()
# Not sure if using the decorator here is actually
# allowed or useful
@stream
def test(request):
return text(type(request.stream))
class TestView(HTTPMethodView):
@stream
async def get(self, request):
return text(type(request.stream))
bp = Blueprint("test")
bp.add_route(test, '/')
bp.add_route(TestView.as_view(), '/class')
app.blueprint(bp, url_prefix='/test')
# Adding this line makes request.stream work FOR ALL ROUTES,
# even those from the blueprint!
# app.add_route(test, '/', stream=True)
app.run(host='0.0.0.0', port=8000)
Expected behavior
Expect request.stream to be set.
Environment (please complete the following information):
Additional context
I am trying to sort this out myself, but the interaction between routes appears very complex. I will submit a pull request if I can get it working.
The text was updated successfully, but these errors were encountered:
If you want to use bp.add_route() with request stream, it seems not working currently because bp.add_route() does not support stream argument. Maybe I can send a PR to make it work.
Describe the bug
When trying to use Request Streaming in a route that is part of a blueprint, the request.stream object is never set (it is None), unless
stream=True
has been set on some global route.Code snippet
Expected behavior
Expect request.stream to be set.
Environment (please complete the following information):
Additional context
I am trying to sort this out myself, but the interaction between routes appears very complex. I will submit a pull request if I can get it working.
The text was updated successfully, but these errors were encountered: