Created
October 24, 2009 19:40
-
-
Save raycmorgan/217710 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.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