Created
November 19, 2010 21:18
-
-
Save indexzero/707193 to your computer and use it in GitHub Desktop.
Sample usage for the proposed addHead addition to ServerResponse
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'); | |
// | |
// Open Questions here: | |
// 1. Does writeHead always have to be called if setHeader is called? | |
// 2. Does writeHead always have to be called with a statusCode? | |
// 3. Can setHeader be called after writeHead? | |
// 4. Does setHeader take a statusCode? | |
// | |
http.createServer(function (req, res) { | |
var content = 'hello, i know nodejs.'; | |
res.setHeader('Content-Length', content.length); | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.setHeader('Should-This', 'Be-Allowed?'); | |
res.write(content); | |
res.end(); | |
}).listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Started repo to implement new response object as a CommonJS module:
https://github.com/Marak/response