Skip to content

Instantly share code, notes, and snippets.

@isaacs isaacs/h.js
Last active Dec 14, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.