Created
December 18, 2011 13:55
-
-
Save cemk/1493486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var url = require('url'); | |
function expand() { | |
var short = url.parse('http://t.co/wbDrgquZ'); | |
var options = { | |
host: short.hostname, | |
port: 80, | |
path: short.pathname | |
}; | |
function longURL(response){ | |
console.log(response.headers.location); | |
} | |
http.get(options, longURL); | |
} | |
function start() { | |
function onRequest(request, response) { | |
console.log("Request received."); | |
response.writeHead(200, {"Content-Type": "text/plain"}); | |
response.write("Hello World"); | |
expand(); | |
response.end(); | |
} | |
http.createServer(onRequest).listen(8888); | |
console.log("Server has started."); | |
} | |
start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment