diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 62ab06e1..0aa163ff 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,11 +2,9 @@
-
-
-
+
@@ -66,12 +64,12 @@
-
+
-
+
@@ -79,11 +77,21 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -140,7 +148,6 @@
- close(
status
createdAt
preInj
@@ -170,6 +177,7 @@
handleRequest(
transform(
grab(
+ json(
_isClosed
@@ -202,7 +210,6 @@
-
@@ -226,6 +233,7 @@
+
@@ -259,6 +267,8 @@
+
+
@@ -355,8 +365,6 @@
-
-
@@ -564,7 +572,9 @@
-
+
+
+
1481237183504
@@ -734,14 +744,21 @@
1499728085186
-
+
+ 1499806099923
+
+
+
+ 1499806099923
+
+
-
+
-
+
@@ -770,7 +787,7 @@
-
+
@@ -790,10 +807,10 @@
-
+
-
+
@@ -805,7 +822,7 @@
-
+
@@ -839,7 +856,8 @@
-
+
+
@@ -924,13 +942,6 @@
-
-
-
-
-
-
-
@@ -1057,20 +1068,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1110,7 +1107,6 @@
-
@@ -1132,7 +1128,6 @@
-
@@ -1148,9 +1143,6 @@
-
-
-
@@ -1199,6 +1191,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1211,12 +1218,20 @@
-
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b4ee3959..d6719ced 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+# 1.0.7+2
+Changed `ResponseContext.serialize`. The `contentType` is now set *before* serialization.
+
# 1.0.7+1
Moved the `Model` class into `package:angel_model`. No functionality was added or removed.
diff --git a/lib/src/http/response_context.dart b/lib/src/http/response_context.dart
index de4e318c..9ce80e0b 100644
--- a/lib/src/http/response_context.dart
+++ b/lib/src/http/response_context.dart
@@ -293,13 +293,14 @@ class ResponseContext extends Extensible implements StringSink {
/// [contentType] can be either a [String], or a [ContentType].
void serialize(value, {contentType}) {
if (_isClosed) throw _closed();
- var text = serializer(value);
- write(text);
if (contentType is String)
headers[HttpHeaders.CONTENT_TYPE] = contentType;
else if (contentType is ContentType) this.contentType = contentType;
+ var text = serializer(value);
+ write(text);
+
end();
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 7f3e4c7e..267e1702 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: angel_framework
-version: 1.0.7+1
+version: 1.0.7+2
description: A high-powered HTTP server with DI, routing and more.
author: Tobe O
homepage: https://github.com/angel-dart/angel_framework