Skip to content

Instantly share code, notes, and snippets.

@darkhelmet
Created November 19, 2010 05:36
Show Gist options
  • Save darkhelmet/706162 to your computer and use it in GitHub Desktop.
Save darkhelmet/706162 to your computer and use it in GitHub Desktop.
var http = require('http'),
sys = require('sys'),
fs = require('fs'),
url = require('url'),
queryString = require('querystring'),
proxy = require('./htmlfiltre'),
YUI = require('yui3').YUI;
http.createServer(function(req, res) {
proxy.htmlFiltre(req, { foreignHost: 'www.instapaper.com', foreignHostPort: 80 }, function (status, buffer, request, response, loc) {
var headers = response.headers;
if (headers['content-type'].match(/text\/html/)) {
YUI({ debug: true }).use('nodejs-dom', 'event', 'node', function(Y) {
// Do something here to get Y.Browser.document with buffer as the HTML document
});
sys.puts(JSON.stringify(response.headers));
sys.puts(buffer);
}
res.writeHead('200', headers);
res.write(buffer, 'utf8');
res.end();
}, function(loc) {
res.writeHead('302', { location: loc });
res.end();
});
}).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment