mde/geddy — pull request #418 by doapp-ryanp (2013-07-16 21:45:18+00:00)
Title: new setRawHeaders and optimize send methods

setRawHeaders() is for when you don't want to set the status code yet (think of your early controller code setting custom header, but later on you may want to return 200 or 201).

for send() quickpath if no content - no need to do content lenth computation and writes().

Here are example usage

```json
this.before(function(){
var res = this.response;

if ('OPTIONS' == this.request.method) {
res.send(null,200,{
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With',
'Access-Control-Max-Age': 5184000 //2 months
});

// OLD way
// res.setHeaders(200,{
// 'Content-Type': 'text/plain',
// 'Access-Control-Allow-Origin': '*',
// 'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS',
// 'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With',
// 'Access-Control-Max-Age': 5184000 //2 months
// });
// res.finish();
return;
}
else {
this.response.setRawHeaders({'Access-Control-Allow-Origin': '*'});
// OLD way
// this.response.resp.setHeader('Access-Control-Allow-Origin', '*');
}
});
```