diff --git a/CHANGELOG.md b/CHANGELOG.md index ef7ad449..e618a19a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.0.0-alpha.14 +* Patch `HttpResponseContext._openStream` to send content-length. + # 2.0.0-alpha.13 - Fixed a logic error in `HttpResponseContext` that prevented status codes from being sent. diff --git a/lib/src/core/response_context.dart b/lib/src/core/response_context.dart index 9a858717..eccea030 100644 --- a/lib/src/core/response_context.dart +++ b/lib/src/core/response_context.dart @@ -20,7 +20,8 @@ final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)'); abstract class ResponseContext implements StreamSink>, StringSink { final Map properties = {}; - final Map _headers = new CaseInsensitiveMap.from({ + final CaseInsensitiveMap _headers = + new CaseInsensitiveMap.from({ 'content-type': 'text/plain', 'server': 'angel', }); @@ -56,7 +57,7 @@ abstract class ResponseContext /// Headers that will be sent to the user. /// /// Note that if you have already started writing to the underlying stream, headers will not persist. - Map get headers => _headers; + CaseInsensitiveMap get headers => _headers; /// Serializes response data into a String. /// diff --git a/lib/src/http/http_response_context.dart b/lib/src/http/http_response_context.dart index 87a9d3fd..50e3c546 100644 --- a/lib/src/http/http_response_context.dart +++ b/lib/src/http/http_response_context.dart @@ -86,6 +86,12 @@ class HttpResponseContext extends ResponseContext { ..statusCode = statusCode ..cookies.addAll(cookies); headers.forEach(rawResponse.headers.set); + + if (headers.containsKey('content-length')) { + rawResponse.contentLength = int.tryParse(headers['content-length']) ?? + rawResponse.contentLength; + } + rawResponse.headers.contentType = new ContentType( contentType.type, contentType.subtype, charset: contentType.parameters['charset'], diff --git a/pubspec.yaml b/pubspec.yaml index 42f0c2c8..ee352e0f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_framework -version: 2.0.0-alpha.13 +version: 2.0.0-alpha.14 description: A high-powered HTTP server with dependency injection, routing and much more. author: Tobe O homepage: https://github.com/angel-dart/angel_framework