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
1 True
2 "the request data"
...
print(ctx_request._body)
^^^^^^^^^^^^^^^^^
AttributeError: '_CachedRequest' object has no attribute '_body'. Did you mean: 'body'?
so, my question is
Why middleware will read body?
Why the ctx_request._body get empty, but the request._body in param is worked
The text was updated successfully, but these errors were encountered:
I'm not sure I understood your question / problem but _body is a private attribute that you should not be accessing or interacting with. Maybe try await request.body()?
LoadingZhang
changed the title
request._body get empty when using middleware to save request to contextvar
request body get empty when using middleware to save request to contextvar
Aug 13, 2024
I'm not sure I understood your question / problem but _body is a private attribute that you should not be accessing or interacting with. Maybe try await request.body()?
@adriangb I used await request.body() before, but it raised an error:
I want to save request to ContextVar so I can use it anywhere. Here is code sample:
Output:
so, my question is
The text was updated successfully, but these errors were encountered: