Skip to content

Instantly share code, notes, and snippets.

@raycmorgan
Created October 24, 2009 19:40
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 raycmorgan/217710 to your computer and use it in GitHub Desktop.
Save raycmorgan/217710 to your computer and use it in GitHub Desktop.
var http = require('/http.js');
var sys = require('/sys.js');
var server = http.createServer(function (request, response) {
request.pause();
request.addListener('body', function (chunk) {
sys.puts("Got body: " + chunk);
});
request.addListener('complete', function () {
var content = "Thank you.";
response.sendHeader(200, {'Content-Length': content.length});
response.sendBody(content);
response.finish();
exit();
});
});
server.listen(8000);
(function () {
var client = http.createClient(8000, '127.0.0.1');
var request = client.post('/', {'content-encoding': 'chunked'});
request.sendBody("Hello");
request.sendBody("World!");
request.finish();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment