Okay I'm trying to get the headers of this specific URL and node.js behaviour baffles me.
My code :
var http = require('http');
var req = http.get("http://listen.radionomy.com/abc-lounge", function(res) {
console.log("headers: ", res.headers);
});
Prints out :
headers: { 'cache-control': 'private', 'content-type': 'text/html; charset=utf-8', server: 'Microsoft-IIS/7.5', 'x-aspnet-version': '4.0.30319', 'x-powered-by': 'ASP.NET', date: 'Tue, 28 Jan 2014 14:18:27 GMT', 'content-length': '8309' }
Now I tried out the command line curl with headers :
This prints out exactly what I'm looking for (The redirect url) :
HTTP/1.1 302 Found
Cache-Control: private
Content-Length: 0
Content-Type: application/octet-stream
Location: http://streaming.radionomy.com/ABC-Lounge
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 5.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 28 Jan 2014 14:19:20 GMT
I don't understand why node is getting a different set of headers. It should not follow redirects by default. I don't even think this is a redirect issue.