This commit is contained in:
Tobe O 2019-08-09 10:53:38 -04:00
parent 67c11b5384
commit 6568dc2305
4 changed files with 24 additions and 21 deletions

View file

@ -5,7 +5,6 @@ import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:angel_wings/angel_wings.dart';
import 'package:io/ansi.dart';
import 'package:pedantic/pedantic.dart';
import 'package:tuple/tuple.dart';
Future<Process> _runWrk(
@ -89,10 +88,11 @@ void _angelIsolate(Tuple2<AngelBenchmark, String> args) {
var app = Angel();
Driver driver;
if (args.item2 == 'angel_http')
if (args.item2 == 'angel_http') {
driver = AngelHttp.custom(app, startShared);
else if (args.item2 == 'angel_wings')
} else if (args.item2 == 'angel_wings') {
driver = AngelWings.custom(app, startSharedWings);
}
await app.configure(args.item1.setupAngel);
await driver.startServer(InternetAddress.loopbackIPv4, testPort);

View file

@ -22,14 +22,14 @@ void prettyLog(LogRecord record) {
/// Chooses a color based on the logger [level].
AnsiCode chooseLogColor(Level level) {
if (level == Level.SHOUT)
if (level == Level.SHOUT) {
return backgroundRed;
else if (level == Level.SEVERE)
} else if (level == Level.SEVERE) {
return red;
else if (level == Level.WARNING)
} else if (level == Level.WARNING) {
return yellow;
else if (level == Level.INFO)
} else if (level == Level.INFO) {
return cyan;
else if (level == Level.FINER || level == Level.FINEST) return lightGray;
} else if (level == Level.FINER || level == Level.FINEST) return lightGray;
return resetAll;
}

View file

@ -9,7 +9,7 @@ import 'wings_socket.dart';
enum _ParseState { method, url, headerField, headerValue, body }
final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
class WingsRequestContext extends RequestContext<WingsClientSocket> {
final WingsClientSocket rawRequest;
@ -91,7 +91,7 @@ class WingsRequestContext extends RequestContext<WingsClientSocket> {
case PURGE:
return 'PURGE';
default:
throw new ArgumentError('Unknown method $method.');
throw ArgumentError('Unknown method $method.');
}
}

View file

@ -57,8 +57,9 @@ class WingsResponseContext extends ResponseContext<int> {
}
}
if (contentType != null)
if (contentType != null) {
outHeaders['content-type'] = contentType.toString();
}
if (encoders.isNotEmpty && correspondingRequest != null) {
if (_allowedEncodings != null) {
@ -66,9 +67,9 @@ class WingsResponseContext extends ResponseContext<int> {
Converter<List<int>, List<int>> encoder;
String key = encodingName;
if (encoders.containsKey(encodingName))
if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName];
else if (encodingName == '*') {
} else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first];
}
@ -116,9 +117,9 @@ class WingsResponseContext extends ResponseContext<int> {
Converter<List<int>, List<int>> encoder;
String key = encodingName;
if (encoders.containsKey(encodingName))
if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName];
else if (encodingName == '*') {
} else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first];
}
@ -131,17 +132,18 @@ class WingsResponseContext extends ResponseContext<int> {
}
return output.forEach((buf) {
if (!_isClosed)
if (!_isClosed) {
writeToNativeSocket(
rawResponse, buf is Uint8List ? buf : Uint8List.fromList(buf));
}
});
}
@override
void add(List<int> data) {
if (_isClosed && isBuffered)
if (_isClosed && isBuffered) {
throw ResponseContext.closed();
else if (!isBuffered) {
} else if (!isBuffered) {
if (!_isClosed) {
_openStream();
@ -151,9 +153,9 @@ class WingsResponseContext extends ResponseContext<int> {
Converter<List<int>, List<int>> encoder;
String key = encodingName;
if (encoders.containsKey(encodingName))
if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName];
else if (encodingName == '*') {
} else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first];
}
@ -168,8 +170,9 @@ class WingsResponseContext extends ResponseContext<int> {
writeToNativeSocket(
rawResponse, data is Uint8List ? data : Uint8List.fromList(data));
}
} else
} else {
buffer.add(data);
}
}
@override