Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: pkg/http_server/lib/src/http_body_impl.dart

Issue 18438005: Move MimeMultipartTransformer and HttpBodyHandler to mime and http_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed _BufferList copy and MimeMultipartException reference in pub. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,
Bill Hesse 2013/07/12 11:43:33 What about an input that ends in half of an encode
Anders Johnsen 2013/07/15 08:21:32 Yes, see line 166.
Bill Hesse 2013/07/15 08:26:33 OK, so controller.close is guaranteed to synchrono
+ onError: (e) => error = e);
+ controller.add(bytes);
+ controller.close();
+ if (error != null) throw error;
+ assert(string != null);
+ return string;
+ }
}
class _HttpBodyFileUpload implements HttpBodyFileUpload {

Powered by Google App Engine
This is Rietveld 408576698