remove charset from json responses. Closes #1631
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 28562b2 · Browse files · 3 files·+8 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+8 added−9 removed
- tests:+8 added−8 removed
- other:+0 added−1 removed
Provenance
- Commit
138d74a- Tree
f08afb4- Author
TJ Holowaychuk <tj@vision-media.ca>- Committer
TJ Holowaychuk <tj@vision-media.ca>- Parent
28562b2
3 files changed+8 added−9 removed
modified:lib/response.js-1 removed
183 unmodified lines184 var spaces = app.get('json spaces');185 var body = JSON.stringify(obj, replacer, spaces);186 187 // content-type188- this.charset = this.charset || 'utf-8';188 this.get('Content-Type') || this.set('Content-Type', 'application/json');189 190 return this.send(body);191 };566 unmodified linesmodified:test/res.json.js+7 added-7 removed
26 unmodified lines272829303131323334359 unmodified lines45464748494950515253545555565758593 unmodified lines6364656667676869707152 unmodified lines1241251261271281281291301311324 unmodified lines13713813914014114114214314414510 unmodified lines15615715815916016016116216316420 unmodified lines26 unmodified lines
request(app) .get('/') .end(function(err, res){ res.headers.should.have.property('content-type', 'application/json; charset=utf-8'); res.headers.should.have.property('content-type', 'application/json'); res.text.should.equal('null'); done(); }) })9 unmodified lines
request(app) .get('/') .end(function(err, res){ res.headers.should.have.property('content-type', 'application/json; charset=utf-8'); res.headers.should.have.property('content-type', 'application/json'); res.text.should.equal('["foo","bar","baz"]'); done(); }) }) })
describe('when given an object', function(){ it('should respond with json', function(done){ var app = express();
3 unmodified lines
request(app) .get('/') .end(function(err, res){ res.headers.should.have.property('content-type', 'application/json; charset=utf-8'); res.headers.should.have.property('content-type', 'application/json'); res.text.should.equal('{"name":"tobi"}'); done(); }) })52 unmodified lines }); }) }) })
describe('.json(status, object)', function(){ it('should respond with json and set the .statusCode', function(done){ var app = express();
4 unmodified lines request(app) .get('/') .end(function(err, res){ res.statusCode.should.equal(201); res.headers.should.have.property('content-type', 'application/json; charset=utf-8'); res.headers.should.have.property('content-type', 'application/json'); res.text.should.equal('{"id":1}'); done(); }) })10 unmodified lines request(app) .get('/') .end(function(err, res){ res.statusCode.should.equal(201); res.headers.should.have.property('content-type', 'application/json; charset=utf-8'); res.headers.should.have.property('content-type', 'application/json'); res.text.should.equal('{"id":1}'); done(); }) })20 unmodified linesmodified:test/res.send.js+1 added-1 removed
200 unmodified lines201 202 request(app)203 .get('/')204 .end(function(err, res){205- res.headers.should.have.property('content-type', 'application/json; charset=utf-8');205+ res.headers.should.have.property('content-type', 'application/json');206 res.text.should.equal('{"name":"tobi"}');207 done();208 })209 })112 unmodified lines