-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Fix request body/POST access #5590
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
cc @D3X, @tomchristie. Hi Tom, see my comment here for context. It seems like setting |
@rpkilby One thing I'm concerned about is that this changes the contract on Normally, Django would set it to an empty With this PR, it gets set to parsed data even for other types, like "application/json". This could result in not-easy-to-track bugs if some middlewares depended on Django's behaviour in this case. |
This shouldn't impact middlewares as they are called with Django's request. DRF's views does the wrapping so it's really used "inside" DRF whether core or the application code. |
@xordoquy I wrote a short test to show how the interface on request.POST changes when using DRF and posting JSON: D3X@aa6a4c4 I don't know any app that would break because of it, but it is possible some would. |
7583b3a
to
feff4c2
Compare
feff4c2
to
278cb68
Compare
@D3X - thanks, good catch. |
@rpkilby This looks fine to me — I'm inclined to just pull it in, but I'm not quite seeing how the commits match the conversation. (Did you rebase? What changed?)
OK, added, but what was this line in the first version?
Thanks! |
@carltongibson - yeah, I amended the commits from earlier in the conversation. Previously was self._request._post = self._data
self._request._files = self._files |
@rpkilby OK, thanks. That makes perfect sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea how this PR works. |
@xordoquy - it's definitely weird, but it won't reenter. eg, if you call |
* Modernize middleware tests * Added a failing test for encode#5582 * Set data ref on underlying django request
This changed as of recent django rest: See encode/django-rest-framework#5590
Supersedes/closes #5583 and fixes #5582.