Index: pkg/http_server/lib/src/http_body_impl.dart |
diff --git a/sdk/lib/io/http_body_impl.dart b/pkg/http_server/lib/src/http_body_impl.dart |
similarity index 91% |
rename from sdk/lib/io/http_body_impl.dart |
rename to pkg/http_server/lib/src/http_body_impl.dart |
index 2eaf07bd791b9e66290e04a28621b464edb2929f..5d52874b1bd4baf89e8bd64ae278db467ad341df 100644 |
--- a/sdk/lib/io/http_body_impl.dart |
+++ b/pkg/http_server/lib/src/http_body_impl.dart |
@@ -2,7 +2,7 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-part of dart.io; |
+part of http_server; |
class _HttpBodyHandlerTransformer |
extends StreamEventTransformer<HttpRequest, HttpRequestBody> { |
@@ -150,6 +150,24 @@ class _HttpBodyHandler { |
return asBinary(); |
} |
+ |
+ // Utility function to synchronously decode a list of bytes. |
+ static String _decodeString(List<int> bytes, |
+ [Encoding encoding = Encoding.UTF_8]) { |
+ if (bytes.length == 0) return ""; |
+ var string; |
+ var error; |
+ var controller = new StreamController(sync: true); |
+ controller.stream |
+ .transform(new StringDecoder(encoding)) |
+ .listen((data) => string = data, |
+ onError: (e) => error = e); |
+ controller.add(bytes); |
+ controller.close(); |
+ if (error != null) throw error; |
+ assert(string != null); |
+ return string; |
+ } |
} |
class _HttpBodyFileUpload implements HttpBodyFileUpload { |