Change signature of ResponseContext.jsonp
This commit is contained in:
parent
2855017d68
commit
696fb8dd81
1 changed files with 3 additions and 9 deletions
|
@ -171,18 +171,12 @@ abstract class ResponseContext implements StreamSink<List<int>>, StringSink {
|
||||||
void json(value) => serialize(value, contentType: 'application/json');
|
void json(value) => serialize(value, contentType: 'application/json');
|
||||||
|
|
||||||
/// Returns a JSONP response.
|
/// Returns a JSONP response.
|
||||||
|
///
|
||||||
|
/// You can override the [contentType] sent; by default it is `application/javascript`.
|
||||||
void jsonp(value, {String callbackName: "callback", MediaType contentType}) {
|
void jsonp(value, {String callbackName: "callback", MediaType contentType}) {
|
||||||
if (!isOpen) throw closed();
|
if (!isOpen) throw closed();
|
||||||
write("$callbackName(${serializer(value)})");
|
write("$callbackName(${serializer(value)})");
|
||||||
|
this.contentType = contentType ?? new MediaType('application', 'javascript');
|
||||||
if (contentType != null) {
|
|
||||||
if (contentType is ContentType)
|
|
||||||
this.contentType = contentType;
|
|
||||||
else
|
|
||||||
headers['content-type'] = contentType.toString();
|
|
||||||
} else
|
|
||||||
headers['content-type'] = 'application/javascript';
|
|
||||||
|
|
||||||
end();
|
end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue