Skip to content

Instantly share code, notes, and snippets.

@isaacs
Last active December 14, 2015 10:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/5069520 to your computer and use it in GitHub Desktop.
Save isaacs/5069520 to your computer and use it in GitHub Desktop.
var http = require('http');
var server = http.createServer(function(req, res) {
req.on('data', function(c) {
console.error('req data %j', c.toString());
});
req.on('end', function() {
console.error('req end');
res.statusCode = 200;
res.setHeader('x-ok', 'yeah whatever');
res.write('flurb\n');
res.write('blerg\n');
res.end('glorb\n');
server.close();
});
});
server.listen(1337);
var client = http.request({
method: 'POST',
headers: { 'content-length': 10 },
port: 1337
});
client.on('data', function(c) {
console.error('CLIENT data %j', c.toString());
});
client.on('end', function() {
console.error('CLIENT end');
});
client.write('hello');
client.write('hello');
client.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment