-
-
Save isaacs/5069520 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'); | |
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