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

Unified Diff: mojo/public/dart/third_party/mime/lib/src/mime_multipart_transformer.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 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: mojo/public/dart/third_party/mime/lib/src/mime_multipart_transformer.dart
diff --git a/mojo/public/dart/third_party/mime/lib/src/mime_multipart_transformer.dart b/mojo/public/dart/third_party/mime/lib/src/mime_multipart_transformer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3afff2dc3b8cf8acf4e7d23fb26d853930242729
--- /dev/null
+++ b/mojo/public/dart/third_party/mime/lib/src/mime_multipart_transformer.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// 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.
+library mime.multipart_transformer;
+
+import 'dart:async';
+import 'dart:typed_data';
+
+import 'bound_multipart_stream.dart';
+import 'mime_shared.dart';
+import 'char_code.dart';
+
+
+Uint8List _getBoundary(String boundary) {
+ var charCodes = boundary.codeUnits;
+
+ var boundaryList = new Uint8List(4 + charCodes.length);
+ // Set-up the matching boundary preceding it with CRLF and two
+ // dashes.
+ boundaryList[0] = CharCode.CR;
+ boundaryList[1] = CharCode.LF;
+ boundaryList[2] = CharCode.DASH;
+ boundaryList[3] = CharCode.DASH;
+ boundaryList.setRange(4, 4 + charCodes.length, charCodes);
+ return boundaryList;
+}
+
+/**
+ * Parser for MIME multipart types of data as described in RFC 2046
+ * section 5.1.1. The data is transformed into [MimeMultipart] objects, each
+ * of them streaming the multipart data.
+ */
+class MimeMultipartTransformer
+ implements StreamTransformer<List<int>, MimeMultipart> {
+
+ final List<int> _boundary;
+
+ /**
+ * Construct a new MIME multipart parser with the boundary
+ * [boundary]. The boundary should be as specified in the content
+ * type parameter, that is without the -- prefix.
+ */
+ MimeMultipartTransformer(String boundary)
+ : _boundary = _getBoundary(boundary);
+
+ Stream<MimeMultipart> bind(Stream<List<int>> stream) {
+ return new BoundMultipartStream(_boundary, stream).stream;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698