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

Side by Side Diff: lib/src/mime_multipart_transformer.dart

Issue 1315033002: pkg/mime: dartfmt most of the code (Closed) Base URL: https://github.com/dart-lang/mime.git@master
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « lib/src/magic_number.dart ('k') | lib/src/mime_type.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library mime.multipart_transformer; 4 library mime.multipart_transformer;
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 import 'bound_multipart_stream.dart'; 9 import 'bound_multipart_stream.dart';
10 import 'mime_shared.dart'; 10 import 'mime_shared.dart';
11 import 'char_code.dart'; 11 import 'char_code.dart';
12 12
13
14 Uint8List _getBoundary(String boundary) { 13 Uint8List _getBoundary(String boundary) {
15 var charCodes = boundary.codeUnits; 14 var charCodes = boundary.codeUnits;
16 15
17 var boundaryList = new Uint8List(4 + charCodes.length); 16 var boundaryList = new Uint8List(4 + charCodes.length);
18 // Set-up the matching boundary preceding it with CRLF and two 17 // Set-up the matching boundary preceding it with CRLF and two
19 // dashes. 18 // dashes.
20 boundaryList[0] = CharCode.CR; 19 boundaryList[0] = CharCode.CR;
21 boundaryList[1] = CharCode.LF; 20 boundaryList[1] = CharCode.LF;
22 boundaryList[2] = CharCode.DASH; 21 boundaryList[2] = CharCode.DASH;
23 boundaryList[3] = CharCode.DASH; 22 boundaryList[3] = CharCode.DASH;
24 boundaryList.setRange(4, 4 + charCodes.length, charCodes); 23 boundaryList.setRange(4, 4 + charCodes.length, charCodes);
25 return boundaryList; 24 return boundaryList;
26 } 25 }
27 26
28 /** 27 /**
29 * Parser for MIME multipart types of data as described in RFC 2046 28 * Parser for MIME multipart types of data as described in RFC 2046
30 * section 5.1.1. The data is transformed into [MimeMultipart] objects, each 29 * section 5.1.1. The data is transformed into [MimeMultipart] objects, each
31 * of them streaming the multipart data. 30 * of them streaming the multipart data.
32 */ 31 */
33 class MimeMultipartTransformer 32 class MimeMultipartTransformer
34 implements StreamTransformer<List<int>, MimeMultipart> { 33 implements StreamTransformer<List<int>, MimeMultipart> {
35
36 final List<int> _boundary; 34 final List<int> _boundary;
37 35
38 /** 36 /**
39 * Construct a new MIME multipart parser with the boundary 37 * Construct a new MIME multipart parser with the boundary
40 * [boundary]. The boundary should be as specified in the content 38 * [boundary]. The boundary should be as specified in the content
41 * type parameter, that is without the -- prefix. 39 * type parameter, that is without the -- prefix.
42 */ 40 */
43 MimeMultipartTransformer(String boundary) 41 MimeMultipartTransformer(String boundary)
44 : _boundary = _getBoundary(boundary); 42 : _boundary = _getBoundary(boundary);
45 43
46 Stream<MimeMultipart> bind(Stream<List<int>> stream) { 44 Stream<MimeMultipart> bind(Stream<List<int>> stream) {
47 return new BoundMultipartStream(_boundary, stream).stream; 45 return new BoundMultipartStream(_boundary, stream).stream;
48 } 46 }
49 } 47 }
OLDNEW
« no previous file with comments | « lib/src/magic_number.dart ('k') | lib/src/mime_type.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698