M
M
MinTnt2021-03-05 18:37:25
Python
MinTnt, 2021-03-05 18:37:25

Why is the data different when posting a request through Fiddler and through requests?

For example, this is how the recorded Fiddler request looks like:

Fiddler
POST https://forum.advance-rp.ru/login/login HTTP/1.1
Host: forum.advance-rp.ru
Connection: keep-alive
Content-Length: 160
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: https://forum.advance-rp.ru
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 OPR/74.0.3911.160
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: https://forum.advance-rp.ru/
Accept-Encoding: gzip, deflate, br
Accept-Language: ru-RU,ru;q=0.9
Cookie: xf_csrf=jTrGjMUxSOJLcpS9; _ym_uid=1614955513148746661; _ym_d=1614955513; _ga=GA1.2.652639445.1614955513; _gid=GA1.2.330162951.1614955513; _ym_isad=2; _ym_visorc=w; xf_session=i16r7tad-F5e_g4YwU97B_hlZ4UTltN4; _gat_gtag_UA_112492973_1=1

login=test%40gmail.com&password=12345&remember=1&_xfRedirect=https%3A%2F%2Fforum.advance-rp.ru%2F&_xfToken=1614956544%2C028d2a16a6bb3d185f017c9ca16c1e3b


With data received at the end in headers
Fiddler Headers
Set-Cookie: xf_user=702023%2CUwuKq7AgMSmoQia4WMuiZ0vz_Se1HxqInLhyWjrY; expires=Sat, 05-Mar-2022 15:15:55 GMT; Max-Age=31536000; path=/; secure; HttpOnly
Set-Cookie: xf_session=V8_gzNsDF4qk5cJ1lKTd1F--nQFFlf4h; path=/; secure; HttpOnly


When trying to replay in Fiddler, everything goes well and I get similar generated cookies. But for some reason, when trying to repeat everything through the requests library, the received data no longer converges
requests
head = {'Content-Length': '160', 'Cache-Control': 'max-age=0', 'Upgrade-Insecure-Requests': '1', 'Origin': 'https://forum.advance-rp.ru', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 OPR/74.0.3911.160', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-User': '?1', 'Sec-Fetch-Dest': 'document', 'Referer': 'https://forum.advance-rp.ru/', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'ru-RU,ru;q=0.9', 'Cookie': 'xf_csrf=jTrGjMUxSOJLcpS9; _ym_uid=1614955513148746661; _ym_d=1614955513; _ga=GA1.2.652639445.1614955513; _gid=GA1.2.330162951.1614955513; _ym_isad=2; _ym_visorc=w; xf_session=i16r7tad-F5e_g4YwU97B_hlZ4UTltN4; _gat_gtag_UA_112492973_1=1'}
data = {'login': '[email protected]', 'password': '12345', 'remember': '1', '_xfRedirect': 'https://forum.advance-rp.ru/', '_xfToken': '1614956544%2C028d2a16a6bb3d185f017c9ca16c1e3b'}
post = requests.post('https://forum.advance-rp.ru/login/login', headers = head, data = data)


The output in headers is already different:
header requests
Set-Cookie': xf_csrf=EV-B5UPddvelaED3; path=/; secure

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MinTnt, 2021-03-28
@MinTnt

I solved the problem a long time ago, I decided to unsubscribe here. Everything was pretty obvious, I just didn’t notice that the request was being redirected. Therefore, when I noticed, I just read the subsequent requests through post.history, and got the cookie sessions I needed from the headers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question