Skip to content

Instantly share code, notes, and snippets.

@w1nk
Created April 22, 2011 19:45
Show Gist options
  • Save w1nk/937440 to your computer and use it in GitHub Desktop.
Save w1nk/937440 to your computer and use it in GitHub Desktop.
var http = require('http');
var util = require('util');
var url = require('url');
http.createServer(function (req, res) {
var parts = url.parse(req.url, true);
var img = parts.query.url;
var parsed = url.parse(img);
util.log(util.inspect(parsed));
var options = {
host: parsed.host,
method: 'GET',
port: 80,
path: parsed.pathname + (parsed.search ? parsed.search : "")
};
var req = http.request(options, function(result)
{
res.writeHead(200, result.headers);
result.on('data', function(chunk)
{
res.write(chunk);
});
});
req.end();
}).listen(8124, "127.0.0.1");
util.log('Server running at http://127.0.0.1:8124/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment