Revert "add response.charset accessor and ctx.charset alias"

This reverts commit 94413b1bd4.
This commit is contained in:
TJ Holowaychuk 2014-03-06 18:05:01 -08:00
parent c50012a636
commit b1f0abd16d
5 changed files with 2 additions and 85 deletions

View file

@ -149,12 +149,10 @@ throw err;
- `ctx.body=` - `ctx.body=`
- `ctx.status` - `ctx.status`
- `ctx.status=` - `ctx.status=`
- `ctx.length`
- `ctx.length=` - `ctx.length=`
- `ctx.type` - `ctx.length`
- `ctx.type=` - `ctx.type=`
- `ctx.charset` - `ctx.type`
- `ctx.charset=`
- `ctx.headerSent` - `ctx.headerSent`
- `ctx.redirect()` - `ctx.redirect()`
- `ctx.attachment()` - `ctx.attachment()`

View file

@ -186,20 +186,6 @@ this.type = 'png';
when explicitly defined in full as `res.type = 'text/html'` when explicitly defined in full as `res.type = 'text/html'`
no charset is assigned. no charset is assigned.
### res.charset
Get response charset when present, or `undefined`:
```js
this.type = 'text/plain; charset=utf-8';
this.charset
// => "utf-8"
```
### res.charset=
Set the response charset, overriding if present.
### res.redirect(url, [alt]) ### res.redirect(url, [alt])
Perform a [302] redirect to `url`. Perform a [302] redirect to `url`.

View file

@ -151,7 +151,6 @@ delegate(proto, 'response')
.access('body') .access('body')
.access('length') .access('length')
.access('type') .access('type')
.access('charset')
.getter('headerSent') .getter('headerSent')
.getter('writable') .getter('writable')
.setter('lastModified') .setter('lastModified')

View file

@ -17,31 +17,6 @@ var extname = path.extname;
module.exports = { module.exports = {
/**
* Set the charset.
*
* @param {String} val
* @api public
*/
set charset(val) {
this.set('Content-Type', this.type + '; charset=' + val);
},
/**
* Get the charset when present or undefined.
*
* @return {String}
* @api public
*/
get charset() {
// TODO: lame, we could have a generic param parsing lib
var type = this.get('Content-Type');
var m = type.match(/charset *= *(\S+)/);
if (m) return m[1];
},
/** /**
* Return the request socket. * Return the request socket.
* *

View file

@ -1,41 +0,0 @@
var context = require('../context');
var assert = require('assert');
describe('ctx.charset=', function(){
describe('with no charset present', function(){
it('should set it', function(){
var ctx = context();
ctx.type = 'text/plain';
ctx.charset = 'utf8';
ctx.response.get('Content-Type').should.equal('text/plain; charset=utf8');
})
})
describe('with a charset', function(){
it('should set it', function(){
var ctx = context();
ctx.type = 'text/plain; charset=hey';
ctx.charset = 'utf8';
ctx.response.get('Content-Type').should.equal('text/plain; charset=utf8');
})
})
})
describe('ctx.charset', function(){
describe('with no charset present', function(){
it('should return null', function(){
var ctx = context();
ctx.type = 'text/plain';
assert(null == ctx.charset);
})
})
describe('with a charset', function(){
it('should return the charset', function(){
var ctx = context();
ctx.type = 'text';
ctx.charset.should.equal('utf-8');
})
})
})