Skip to content

Instantly share code, notes, and snippets.

@koichik
Created October 7, 2011 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koichik/1270121 to your computer and use it in GitHub Desktop.
Save koichik/1270121 to your computer and use it in GitHub Desktop.
node-http-proxy test case for HTTP/1.0
var net = require('net');
var http = require('http');
var httpProxy = require('./node-http-proxy');
var server = http.createServer(function(req, res) {
res.write('Hello, ');
res.end('World\n');
});
server.listen(8000, 'localhost', function() {
var proxy = httpProxy.createServer(8000, 'localhost');
proxy.listen(9000, function() {
var socket = net.createConnection(9000, function() {
socket.write('GET / HTTP/1.0\r\n\r\n');
});
socket.setEncoding('utf8');
socket.on('data', console.log);
socket.on('end', function() {
proxy.close();
server.close();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment