mercredi 5 octobre 2016

Curl and Laravel, always redirects

I am trying to do a simple simple curl to a Laravel (5.2) app running on my machine:

curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1" http://ift.tt/2dIGnaT

With this result:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="refresh" content="1;url=http://ift.tt/2dIGnaT" />
    <title>Redirecting to http://ift.tt/2d2tsmU;
    </head>
    <body>
        Redirecting to <a href="http://ift.tt/2dIGnaT">http://ift.tt/2dIHgAo;.
    </body>
</html>

I find this really weird since if i use the lib requests from python 3.x:

import requests

headers = {'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1'}
req = requests.get('http://ift.tt/2d2sS8s', headers=headers)
print(req.text)

The response is all html from the page (this is what is supose to happen)

PS: I also used the -L flag with me curl so it can fallow redirects but it appears to end up in an infinite loop (curl: (47) Maximum (50) redirects followed)

Why is this hapening? How to solve it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire