2.0.0-alpha.14

This commit is contained in:
Tobe O 2018-11-13 18:33:44 -05:00
parent dde983245d
commit 8ca8a9af3f
4 changed files with 13 additions and 3 deletions

View file

@ -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.

View file

@ -20,7 +20,8 @@ final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
abstract class ResponseContext<RawResponse>
implements StreamSink<List<int>>, StringSink {
final Map properties = {};
final Map<String, String> _headers = new CaseInsensitiveMap.from({
final CaseInsensitiveMap<String> _headers =
new CaseInsensitiveMap<String>.from({
'content-type': 'text/plain',
'server': 'angel',
});
@ -56,7 +57,7 @@ abstract class ResponseContext<RawResponse>
/// 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<String, String> get headers => _headers;
CaseInsensitiveMap<String> get headers => _headers;
/// Serializes response data into a String.
///

View file

@ -86,6 +86,12 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
..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'],

View file

@ -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 <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_framework