diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
index e74764aa..ad9897bb 100644
--- a/.idea/libraries/Dart_Packages.xml
+++ b/.idea/libraries/Dart_Packages.xml
@@ -5,7 +5,7 @@
-
+
@@ -33,35 +33,35 @@
-
+
-
+
-
+
-
+
-
+
@@ -82,7 +82,7 @@
-
+
@@ -110,14 +110,14 @@
-
+
-
+
@@ -131,7 +131,7 @@
-
+
@@ -145,7 +145,7 @@
-
+
@@ -166,14 +166,14 @@
-
+
-
+
@@ -208,7 +208,7 @@
-
+
@@ -222,7 +222,7 @@
-
+
@@ -236,21 +236,21 @@
-
+
-
+
-
+
@@ -264,7 +264,7 @@
-
+
@@ -306,7 +306,7 @@
-
+
@@ -327,7 +327,7 @@
-
+
@@ -348,7 +348,7 @@
-
+
@@ -362,7 +362,7 @@
-
+
@@ -376,14 +376,14 @@
-
+
-
+
@@ -404,7 +404,7 @@
-
+
@@ -425,21 +425,21 @@
-
+
-
+
-
+
@@ -453,69 +453,69 @@
-
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 513c70c2..615a333c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,11 +1,14 @@
-
-
+
+
+
+
+
@@ -28,40 +31,25 @@
-
-
+
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
+
@@ -70,42 +58,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -116,8 +70,70 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -135,9 +151,6 @@
- handleRe
- instead.
- io\b
_isOpen
_isClosed
end
@@ -155,7 +168,6 @@
error
trace
zonesp
- close(
runGuar
unca
async
@@ -165,6 +177,10 @@
zone
zone.run
aaa
+ close(
+ statusCode
+ .run
+ var body = await rs.fold<List<int>>([], (out, list) => []..addAll(list));
_isClosed
@@ -194,6 +210,7 @@
!isOpen
'server'
FutureOr
+ var body = await getBody(rs);
C:\Users\thosa\Source\Angel\framework\lib
@@ -220,8 +237,6 @@
@@ -305,9 +322,9 @@
-
+
@@ -318,7 +335,7 @@
-
+
@@ -364,7 +381,7 @@
-
+
@@ -491,6 +508,11 @@
+
+
+
+
+
@@ -549,7 +571,7 @@
-
+
@@ -591,7 +613,13 @@
+
+
+
+
+
+
@@ -666,14 +694,8 @@
-
-
-
- 1506089003709
-
-
-
- 1506089003709
+
+
1506089080836
@@ -1011,43 +1033,50 @@
1526436313662
-
+
+ 1526438457813
+
+
+
+ 1526438457813
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -1085,7 +1114,6 @@
-
@@ -1096,6 +1124,7 @@
+
@@ -1140,35 +1169,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1310,20 +1310,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1335,7 +1321,6 @@
-
@@ -1364,13 +1349,12 @@
-
-
+
@@ -1385,35 +1369,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1440,7 +1399,7 @@
-
+
@@ -1452,7 +1411,7 @@
-
+
@@ -1460,19 +1419,9 @@
-
-
-
-
-
-
-
-
-
-
-
+
@@ -1489,16 +1438,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1515,16 +1454,118 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.travis.yml b/.travis.yml
index 274209f9..34a2a649 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,5 @@
language: dart
+dart:
+ - dev
before_script: chmod +x ./tool/travis.sh
script: ./tool/travis.sh
\ No newline at end of file
diff --git a/lib/src/http/angel_http.dart b/lib/src/http/angel_http.dart
index 31b8a6e8..3682d17d 100644
--- a/lib/src/http/angel_http.dart
+++ b/lib/src/http/angel_http.dart
@@ -118,6 +118,8 @@ class AngelHttp {
if (error is FormatException) {
e = new AngelHttpException.badRequest(message: error.message);
+ } else if (error is AngelHttpException) {
+ e = error;
} else {
e = new AngelHttpException(error,
stackTrace: stackTrace, message: error?.toString());
diff --git a/test/encoders_buffer_test.dart b/test/encoders_buffer_test.dart
index cdda8179..720cc2e4 100644
--- a/test/encoders_buffer_test.dart
+++ b/test/encoders_buffer_test.dart
@@ -1,9 +1,17 @@
+import 'dart:async';
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:dart2_constant/convert.dart';
import 'package:mock_request/mock_request.dart';
import 'package:test/test.dart';
+Future> getBody(MockHttpResponse rs) async {
+ var list = await rs.toList();
+ var bb = new BytesBuilder();
+ list.forEach(bb.add);
+ return bb.takeBytes();
+}
+
main() {
Angel app;
@@ -52,7 +60,7 @@ void encodingTests(Angel getApp()) {
var rs = rq.response;
await http.handleRequest(rq);
- var body = await rs.fold>([], (out, list) => []..addAll(list));
+ var body = await getBody(rs);
expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'deflate');
expect(body, ZLIB.encode(utf8.encode('Hello, world!')));
});
@@ -64,7 +72,7 @@ void encodingTests(Angel getApp()) {
var rs = rq.response;
await http.handleRequest(rq);
- var body = await rs.fold>([], (out, list) => []..addAll(list));
+ var body = await getBody(rs);
expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'deflate');
expect(body, ZLIB.encode(utf8.encode('Hello, world!')));
});
@@ -76,7 +84,7 @@ void encodingTests(Angel getApp()) {
var rs = rq.response;
await http.handleRequest(rq);
- var body = await rs.fold>([], (out, list) => []..addAll(list));
+ var body = await getBody(rs);
expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'gzip');
expect(body, GZIP.encode(utf8.encode('Hello, world!')));
});
@@ -87,8 +95,8 @@ void encodingTests(Angel getApp()) {
await rq.close();
var rs = rq.response;
await http.handleRequest(rq);
-
- var body = await rs.fold>([], (out, list) => []..addAll(list));
+
+ var body = await getBody(rs);
expect(rs.headers.value(HttpHeaders.CONTENT_ENCODING), 'gzip');
expect(body, GZIP.encode(utf8.encode('Hello, world!')));
});
diff --git a/test/parameter_meta_test.dart b/test/parameter_meta_test.dart
index 198cd2d8..ba55578c 100644
--- a/test/parameter_meta_test.dart
+++ b/test/parameter_meta_test.dart
@@ -1,12 +1,12 @@
import 'dart:async';
-import 'dart:convert';
+import 'package:dart2_constant/convert.dart';
import 'package:angel_framework/angel_framework.dart';
import 'package:logging/logging.dart';
import 'package:mock_request/mock_request.dart';
import 'package:test/test.dart';
Future readResponse(MockHttpResponse rs) {
- return rs.transform(UTF8.decoder).join();
+ return rs.transform(utf8.decoder).join();
}
Future printResponse(MockHttpResponse rs) {
@@ -63,7 +63,7 @@ main() {
// Invalid request
var rq = new MockHttpRequest('GET', Uri.parse('/header'))..close();
var rs = rq.response;
- await http.handleRequest(rq);
+ http.handleRequest(rq);
await printResponse(rs);
expect(rs.statusCode, 400);
@@ -78,15 +78,14 @@ main() {
var body = await readResponse(rs);
print('Body: $body');
expect(rs.statusCode, 200);
- expect(body, JSON.encode('bar'));
- print('done');
+ expect(body, json.encode('bar'));
});
test('injects session or throws', () async {
// Invalid request
var rq = new MockHttpRequest('GET', Uri.parse('/session'))..close();
var rs = rq.response;
- await http.handleRequest(rq).timeout(const Duration(seconds: 5)).catchError((_) => null);
+ http.handleRequest(rq).timeout(const Duration(seconds: 5)).catchError((_) => null);
await printResponse(rs);
expect(rs.statusCode, 500);
@@ -96,7 +95,7 @@ main() {
rq.session['foo'] = 'bar';
rq.close();
rs = rq.response;
- await http.handleRequest(rq);
+ http.handleRequest(rq);
await printResponse(rs);
expect(rs.statusCode, 200);
@@ -109,27 +108,27 @@ main() {
test('pattern matching', () async {
var rq = new MockHttpRequest('GET', Uri.parse('/match?mode=pos'))..close();
var rs = rq.response;
- await http.handleRequest(rq);
+ http.handleRequest(rq);
var body = await readResponse(rs);
print('Body: $body');
expect(rs.statusCode, 200);
- expect(body, JSON.encode('YES pos'));
+ expect(body, json.encode('YES pos'));
rq = new MockHttpRequest('GET', Uri.parse('/match?mode=neg'))..close();
rs = rq.response;
- await http.handleRequest(rq);
+ http.handleRequest(rq);
body = await readResponse(rs);
print('Body: $body');
expect(rs.statusCode, 200);
- expect(body, JSON.encode('NO neg'));
+ expect(body, json.encode('NO neg'));
// Fallback
rq = new MockHttpRequest('GET', Uri.parse('/match?mode=ambi'))..close();
rs = rq.response;
- await http.handleRequest(rq);
+ http.handleRequest(rq);
body = await readResponse(rs);
print('Body: $body');
expect(rs.statusCode, 200);
- expect(body, JSON.encode('DEFAULT ambi'));
+ expect(body, json.encode('DEFAULT ambi'));
});
}
diff --git a/test/server_test.dart b/test/server_test.dart
index 4e67aa47..fec73b5f 100644
--- a/test/server_test.dart
+++ b/test/server_test.dart
@@ -173,7 +173,8 @@ main() {
var rq = new MockHttpRequest('GET', new Uri(path: 'wtf'))
..headers.set(HttpHeaders.ACCEPT, ContentType.JSON.toString());
rq.close();
- await http.handleRequest(rq);
+ http.handleRequest(rq);
+ await rq.response.toList();
expect(rq.response.statusCode, HttpStatus.FORBIDDEN);
expect(
rq.response.headers.contentType.mimeType, ContentType.JSON.mimeType);
@@ -183,7 +184,8 @@ main() {
var rq = new MockHttpRequest('GET', new Uri(path: 'wtf'))
..headers.set(HttpHeaders.ACCEPT, ContentType.JSON.toString());
rq.close();
- await http.handleRequest(rq);
+ http.handleRequest(rq);
+ await rq.response.toList();
expect(rq.response.statusCode, HttpStatus.FORBIDDEN);
expect(
rq.response.headers.contentType.mimeType, ContentType.JSON.mimeType);
@@ -193,7 +195,8 @@ main() {
var rq = new MockHttpRequest('GET', new Uri(path: 'wtf2'));
rq.headers.set(HttpHeaders.ACCEPT, ContentType.HTML.toString());
rq.close();
- await http.handleRequest(rq);
+ http.handleRequest(rq);
+ await rq.response.toList();
expect(rq.response.statusCode, HttpStatus.FORBIDDEN);
expect(
rq.response.headers.contentType?.mimeType, ContentType.HTML.mimeType);