From 696fb8dd81ba8511565d991bc0196984c5e51010 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 19 Aug 2018 11:40:49 -0400 Subject: [PATCH] Change signature of ResponseContext.jsonp --- lib/src/core/response_context.dart | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/src/core/response_context.dart b/lib/src/core/response_context.dart index 7d94424c..c4a6ed83 100644 --- a/lib/src/core/response_context.dart +++ b/lib/src/core/response_context.dart @@ -171,18 +171,12 @@ abstract class ResponseContext implements StreamSink>, StringSink { void json(value) => serialize(value, contentType: 'application/json'); /// Returns a JSONP response. + /// + /// You can override the [contentType] sent; by default it is `application/javascript`. void jsonp(value, {String callbackName: "callback", MediaType contentType}) { if (!isOpen) throw closed(); write("$callbackName(${serializer(value)})"); - - if (contentType != null) { - if (contentType is ContentType) - this.contentType = contentType; - else - headers['content-type'] = contentType.toString(); - } else - headers['content-type'] = 'application/javascript'; - + this.contentType = contentType ?? new MediaType('application', 'javascript'); end(); }