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