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

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: Remove import. 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
« no previous file with comments | « pkg/http_server/lib/src/http_body.dart ('k') | pkg/http_server/lib/src/http_multipart_form_data.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « pkg/http_server/lib/src/http_body.dart ('k') | pkg/http_server/lib/src/http_multipart_form_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698