Skip to content
Myr

jsonp text/javascript as per mailinglist discussion

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 c0f9642 · Browse files · 2 files+3 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−2 removed

  • tests:+2 added−2 removed
  • other:+1 added−0 removed

2 files+3 added−2 removed

modified:lib/express/response.js+1 added
82 unmodified lines
83 this.contentType('.json');84 }85 body = JSON.stringify(body);86 if (this.req.query.callback && this.app.settings['jsonp callback']) {87 this.header('Content-Type', 'text/javascript');88 body = this.req.query.callback + '(' + body + ');';89 }90 }91 break;
280 unmodified lines
modified:test/response.test.js+2 added-2 removed
55 unmodified lines
56 { body: '{"foo":"bar"}', status: 201, headers: { 'Content-Type': 'application/json', 'X-Foo': 'baz' }});5758 assert.response(app,59 { url: '/jsonp?callback=test' },60 { body: 'test({"foo":"bar"});', status: 201, headers: { 'Content-Type': 'application/json', 'X-Foo': 'baz' }});60 { body: 'test({"foo":"bar"});', status: 201, headers: { 'Content-Type': 'text/javascript', 'X-Foo': 'baz' }});6162 assert.response(app,63 { url: '/jsonp?callback=baz' },64 { body: 'baz({"foo":"bar"});', status: 201, headers: { 'Content-Type': 'application/json', 'X-Foo': 'baz' }});64 { body: 'baz({"foo":"bar"});', status: 201, headers: { 'Content-Type': 'text/javascript', 'X-Foo': 'baz' }});6566 assert.response(app,67 { url: '/json?callback=test' },68 { body: '{"foo":"bar"}', status: 201, headers: { 'Content-Type': 'application/json', 'X-Foo': 'baz' }});
340 unmodified lines