kennethreitz/requests — pull request #502 by maxcountryman (2012-03-21 12:39:00+00:00)
Title: making `body` an attribute of the request object; maybe fixes #445

This occurred to me as a potential workaround for issues with pre-request hooks
being unable to alter `body` within their scope. Particularly those found in
oauth-requests, where the body of a request cannot be recalculated. Here the
issue seems to be that `body` is assigned as a local variable. So if we simply
make `body` an attribute of the object we can manually override its value in
the scope of the hook. Here is a simple example of what this might look like:
`request.data, request._enc_data = request._encode_params(my_params)` this sets
us up for `request.body = request._enc_data` and we can now alter body as we
should like.