Empty body when using requests.post() that follows a 302

Hi, 

I have Python 3.7.1 and requests 2.19.1 installed and I am doing a POST to an endpoint that returns 302, apparently requests.post is not sending the body.

If I run this, it works fine:

`response = s.post('https://my-url', headers=headers, data=json.dumps(data))`

But when I run the code bellow, it fails:

`response = requests.post('https://my-url', headers=headers, data=json.dumps(data))`

I get this response from the server:
`'{"message":"Required parameter tag is missing"}'`

Which in my case would either mean a bad JSON object payload or an empty request body. Checking the server logs, I can see that the request body is empty.

Is this behavior expected? Am I doing something wrong?

Thanks in advance.

You may set something in session, since this works:

```
response = s.post('https://my-url', headers=headers, data=json.dumps(data))
```

so use `requests.post` won't use the old session, it will start a new session instead.

Hi,
Thanks for the answer.

But if that was the case I would get a 401 or 403, right? And I see the request getting to the server.

Also, if I do curl with --post302 (not setting a cookie), also works.

Can you try to post to `http://httpbin.org/post` ?  This site will echo your request data.

And if you can give a runnable requests snippet I can help you debug.

Everything is identical. 

But this is a straight POST, in my case I have at least three 302s going and I think request.post it's not sending the body after the redirects.

I'll try to do some more digging. 

Thanks again.

Here's the snippet:

```
import requests
import json

s = requests.Session()

headers = {
    'Content-Type': 'application/json',
    'Accept': '*/*',
    'Authorization': 'Bearer <redacted>'
}

data = {"<key>":{"<key>":"<value>","<key>":"<value>","<key>":"<value>"}, "<key>":[{"<key>":"<value>","<key>":"<value>","reference":"<value>"}]}
# Works
response = s.post('https://<my-url>', headers=headers, data=json.dumps(data))
# Doesn't work:
response = requests.post('https://<my-url>', headers=headers, data=json.dumps(data))
```

Again, curl with --post302 works. From curl docs:

> --post302
> 
> (HTTP) Tells curl to respect RFC 7231/6.4.3 and not convert POST requests into GET requests when following a 302 redirection. The non-RFC behaviour is ubiquitous in web browsers, so curl does the conversion by default to maintain consistency. However, a server may require a POST to remain a POST after such a redirection. This option is meaningful only when using -L, --location.
> 
> See also --post301 and --post303 and -L, --location. Added in 7.19.1.
> 

I haven't looked at the difference in requests yet, but I guess s.post is not converting the POST into GET and requests.post is, that's why body is not sent (doesn't make sense for a  GET).

Hi, I tried post to a 302 URL using flask, it turns out that both `request` and `session` doesn't post data for 302, only curl with `--post302` works.

Here's flask simple server:
```
# -*- coding: utf-8 -*-
from flask import Flask, redirect, request
app = Flask(__name__)

@app.route("/redirect_post", methods=['GET', 'POST'])
def hello():
    return redirect("/real_post")

@app.route('/real_post', methods=['GET', 'POST'])
def login():
    print(request.form)
    print(request.data)
    return request.data
```

Here's curl test:
```
curl -Xpost -d "data=something" http://127.0.0.1:5000/redirect_post -L

127.0.0.1 - - [22/Feb/2019 14:26:39] "post /redirect_post HTTP/1.1" 302 -
ImmutableMultiDict([])
b''
127.0.0.1 - - [22/Feb/2019 14:26:39] "post /real_post HTTP/1.0" 200 -

curl -Xpost -d "data=something" http://127.0.0.1:5000/redirect_post -L --post302

127.0.0.1 - - [22/Feb/2019 14:26:57] "post /redirect_post HTTP/1.1" 302 -
ImmutableMultiDict([('data', 'something')])
b''
127.0.0.1 - - [22/Feb/2019 14:26:57] "post /real_post HTTP/1.0" 200 -
```

And here is requests' test:

```
import requests

s = requests.Session()
s.post("http://127.0.0.1:5000/redirect_post", json={"hello": "world"})
requests.post("http://127.0.0.1:5000/redirect_post", json={"hello": "world"})

127.0.0.1 - - [22/Feb/2019 14:27:27] "POST /redirect_post HTTP/1.1" 302 -
ImmutableMultiDict([])
b''
127.0.0.1 - - [22/Feb/2019 14:27:27] "GET /real_post HTTP/1.1" 200 -
127.0.0.1 - - [22/Feb/2019 14:27:27] "POST /redirect_post HTTP/1.1" 302 -
ImmutableMultiDict([])
b''
127.0.0.1 - - [22/Feb/2019 14:27:27] "GET /real_post HTTP/1.1" 200 -
```
It shows that requests turn method to `GET` when redirect.



Same issue here. A POST request ends up in a 302 redirection and requests sends a GET to the new location.

It looks like requests is not respecting the HTTP method on redirections

![captura](https://user-images.githubusercontent.com/19838369/53338398-d9024300-3903-11e9-94b4-23093c2b07fd.PNG)

@bernardomk you can use the [history property](http://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history) to track those redirections and see what happened

@bernardomk  Is there an update?

@dmnava It's expected behavior to convert POST into GET during a 302 redirect.

HTTP 307 can ensure client keep HTTP method while redirecting.

https://zh.wikipedia.org/wiki/HTTP_307