curltinyurl

Tiny URL redirection works in browser, but from curl returns 200 instead of 301


This looks weird to me, may be I'm missing something obvious. Following is a sample tinyurl:

http://tinyurl.com/67lwfe

it works for my browser, redirects properly to the desired page. But when I try using curl like the following:

curl -I http://tinyurl.com/67lwfe

It responds with 200 instead of a 3xx response. I thought the page might be responding with a meta refresh html tag, so I tried:

curl http://tinyurl.com/67lwfe

But it responds blank with no html or meta refresh tags. So my question is how the browser knows to redirect properly? I've also tried setting browser agents with no luck. Am I missing something obvious?


Solution

  • tinyurl appears to serve a 200 with a <meta http-equiv="Refresh"> initially, then 301s for subsequent requests for some amount of time afterwards, so that it can set cookies (two of them!), run a ton of tracking scripts, and just generally slow people down.

    That is to say, tinyurl sucks, and so do all URL shorteners. Good question.