From 6ae68f70b6a6a81e1c49be9f6138ec909d6f1922 Mon Sep 17 00:00:00 2001 From: coryrwest Date: Mon, 23 Dec 2013 15:54:07 -0800 Subject: [PATCH] Update crimsonTest.dart with new syntax Update crimsonTest.dart with new syntax for latest Dart release. Not quite sure about the safety of line 39. --- example/crimsonTest.dart | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/example/crimsonTest.dart b/example/crimsonTest.dart index efdcffb..e4458b5 100644 --- a/example/crimsonTest.dart +++ b/example/crimsonTest.dart @@ -34,28 +34,23 @@ Future setTemplateData(HttpRequest req,HttpResponse res,var data) { print(data); StringBuffer sb = new StringBuffer(); - req.inputStream.onData = () { + req.listen((data) { print("setTemplateData onData"); - sb.add(decodeUtf8(req.inputStream.read(req.inputStream.available()))); - }; - - req.inputStream.onClosed = () { + req.transform(new Utf8Decoder()).listen((data) { sb.write(data); }); + }, onDone: (() { print("setTemplateData onClose"); print(sb.toString()); - - res.outputStream.writeString(sb.toString()); + res.write(sb.toString()); c.complete(null); - }; - - req.inputStream.onError = (e) { + }), onError: ((e) { print("setTemplateData onError"); print("error $e"); c.complete(null); - }; + })); return c.future; } //bool matcherFunction(HttpRequest req) { // return req.path.endsWith("matcher"); -//} \ No newline at end of file +//}