kennethreitz/requests — Issue #445: Impossible to alter body in hooks
Author: maraujop
Created: 2012-02-20 19:25:46+00:00
State: open

As you can see in this line:
https://github.com/kennethreitz/requests/blob/develop/requests/models.py#L524

Body is precalculated and there is no way to alter it in a hook. It should be calculated after the hook. So if the hook alters `data` or `files`, it gets updated.

Example. If I do this with requests-oauth:

```python
response = client.post('http://api.twitter.com/oauth/request_token', {'oauth_callback': 'oob'})
```

If I'm doing requests-oauth to avoid throwing `oauth_*` porameters into body, if header authentication is set. There is no way I can do this. This forces me to add an extra parameter for requests-oauth that is only used in connection initialization.

I'm not submitting a patch, as this can be fixed several ways and it might have some side-effects I'm not aware of.

Cheers,
Miguel