Created
November 19, 2010 05:36
-
-
Save darkhelmet/706162 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'), | |
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