OLD | NEW |
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 | 4 |
5 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * Parser for MIME multipart types of data as described in RFC 2046 | 8 * Parser for MIME multipart types of data as described in RFC 2046 |
9 * section 5.1.1. The data to parse is supplied through the [:update:] | 9 * section 5.1.1. The data to parse is supplied through the [:update:] |
10 * method. As the data is parsed the following callbacks are called: | 10 * method. As the data is parsed the following callbacks are called: |
(...skipping 24 matching lines...) Expand all Loading... |
35 const int _LAST_BOUNDARY_ENDING = 12; | 35 const int _LAST_BOUNDARY_ENDING = 12; |
36 const int _LAST_BOUNDARY_END = 13; | 36 const int _LAST_BOUNDARY_END = 13; |
37 const int _DONE = 14; | 37 const int _DONE = 14; |
38 const int _FAILURE = 15; | 38 const int _FAILURE = 15; |
39 | 39 |
40 // Construct a new MIME multipart parser with the boundary | 40 // Construct a new MIME multipart parser with the boundary |
41 // [boundary]. The boundary should be as specified in the content | 41 // [boundary]. The boundary should be as specified in the content |
42 // type parameter, that is without the -- prefix. | 42 // type parameter, that is without the -- prefix. |
43 _MimeMultipartParser(String boundary) { | 43 _MimeMultipartParser(String boundary) { |
44 List<int> charCodes = boundary.charCodes; | 44 List<int> charCodes = boundary.charCodes; |
45 _boundary = new List<int>(4 + charCodes.length); | 45 _boundary = new List<int>.fixedLength(4 + charCodes.length); |
46 // Set-up the matching boundary preceding it with CRLF and two | 46 // Set-up the matching boundary preceding it with CRLF and two |
47 // dashes. | 47 // dashes. |
48 _boundary[0] = _CharCode.CR; | 48 _boundary[0] = _CharCode.CR; |
49 _boundary[1] = _CharCode.LF; | 49 _boundary[1] = _CharCode.LF; |
50 _boundary[2] = _CharCode.DASH; | 50 _boundary[2] = _CharCode.DASH; |
51 _boundary[3] = _CharCode.DASH; | 51 _boundary[3] = _CharCode.DASH; |
52 _boundary.setRange(4, charCodes.length, charCodes); | 52 _boundary.setRange(4, charCodes.length, charCodes); |
53 _state = _START; | 53 _state = _START; |
54 _headerField = new StringBuffer(); | 54 _headerField = new StringBuffer(); |
55 _headerValue = new StringBuffer(); | 55 _headerValue = new StringBuffer(); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 Function partDataReceived; | 324 Function partDataReceived; |
325 Function partEnd; | 325 Function partEnd; |
326 } | 326 } |
327 | 327 |
328 | 328 |
329 class MimeParserException implements Exception { | 329 class MimeParserException implements Exception { |
330 const MimeParserException([String this.message = ""]); | 330 const MimeParserException([String this.message = ""]); |
331 String toString() => "MimeParserException: $message"; | 331 String toString() => "MimeParserException: $message"; |
332 final String message; | 332 final String message; |
333 } | 333 } |
OLD | NEW |