change ctx.length and ctx.type to always delegate to response object [breaking change]

This commit is contained in:
TJ Holowaychuk 2014-02-14 09:16:39 -08:00
parent 4efd645bfd
commit 08149052fa
2 changed files with 8 additions and 7 deletions

View file

@ -149,11 +149,11 @@ delegate(proto, 'response')
.method('set')
.access('status')
.access('body')
.access('length')
.access('type')
.getter('headerSent')
.setter('lastModified')
.setter('length')
.setter('etag')
.setter('type');
.setter('etag');
/**
* Request delegation.
@ -175,13 +175,11 @@ delegate(proto, 'request')
.access('path')
.access('host')
.access('url')
.getter('length')
.getter('subdomains')
.getter('protocol')
.getter('header')
.getter('secure')
.getter('stale')
.getter('fresh')
.getter('type')
.getter('ips')
.getter('ip');

View file

@ -7,6 +7,7 @@ describe('ctx.type=', function(){
it('should set the Content-Type', function(){
var ctx = context();
ctx.type = 'text/plain';
ctx.type.should.equal('text/plain');
ctx.response.header['content-type'].should.equal('text/plain');
})
})
@ -15,6 +16,7 @@ describe('ctx.type=', function(){
it('should lookup the mime', function(){
var ctx = context();
ctx.type = 'json';
ctx.type.should.equal('application/json');
ctx.response.header['content-type'].should.equal('application/json');
})
})
@ -24,6 +26,7 @@ describe('ctx.type', function(){
describe('with no Content-Type', function(){
it('should return null', function(){
var ctx = context();
// TODO: this is lame
assert(null == ctx.type);
})
})
@ -31,8 +34,8 @@ describe('ctx.type', function(){
describe('with a Content-Type', function(){
it('should return the mime', function(){
var ctx = context();
ctx.req.headers['content-type'] = 'text/html; charset=utf8';
ctx.type.should.equal('text/html');
ctx.type = 'json';
ctx.type.should.equal('application/json');
})
})
})