| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.bound_multipart_stream; | 4 library mime.bound_multipart_stream; |
| 5 | 5 |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'mime_shared.dart'; | 9 import 'mime_shared.dart'; |
| 10 import 'char_code.dart'; | 10 import 'char_code.dart'; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // The following states belong to `_controller`, state changes will not be | 74 // The following states belong to `_controller`, state changes will not be |
| 75 // immediately acted upon but rather only after the current | 75 // immediately acted upon but rather only after the current |
| 76 // `_multipartController` is done. | 76 // `_multipartController` is done. |
| 77 static const int _CONTROLLER_STATE_IDLE = 0; | 77 static const int _CONTROLLER_STATE_IDLE = 0; |
| 78 static const int _CONTROLLER_STATE_ACTIVE = 1; | 78 static const int _CONTROLLER_STATE_ACTIVE = 1; |
| 79 static const int _CONTROLLER_STATE_PAUSED = 2; | 79 static const int _CONTROLLER_STATE_PAUSED = 2; |
| 80 static const int _CONTROLLER_STATE_CANCELED = 3; | 80 static const int _CONTROLLER_STATE_CANCELED = 3; |
| 81 | 81 |
| 82 int _controllerState = _CONTROLLER_STATE_IDLE; | 82 int _controllerState = _CONTROLLER_STATE_IDLE; |
| 83 | 83 |
| 84 StreamController _controller; | 84 StreamController<MimeMultipart> _controller; |
| 85 | 85 |
| 86 Stream<MimeMultipart> get stream => _controller.stream; | 86 Stream<MimeMultipart> get stream => _controller.stream; |
| 87 | 87 |
| 88 StreamSubscription _subscription; | 88 StreamSubscription _subscription; |
| 89 | 89 |
| 90 StreamController _multipartController; | 90 StreamController<List<int>> _multipartController; |
| 91 Map<String, String> _headers; | 91 Map<String, String> _headers; |
| 92 | 92 |
| 93 int _state = _START; | 93 int _state = _START; |
| 94 int _boundaryIndex = 2; | 94 int _boundaryIndex = 2; |
| 95 | 95 |
| 96 // Current index in the data buffer. If index is negative then it | 96 // Current index in the data buffer. If index is negative then it |
| 97 // is the index into the artificial prefix of the boundary string. | 97 // is the index into the artificial prefix of the boundary string. |
| 98 int _index; | 98 int _index; |
| 99 List<int> _buffer; | 99 List<int> _buffer; |
| 100 | 100 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 372 } |
| 373 | 373 |
| 374 // Resume if at end. | 374 // Resume if at end. |
| 375 if (_index == _buffer.length) { | 375 if (_index == _buffer.length) { |
| 376 _buffer = null; | 376 _buffer = null; |
| 377 _index = null; | 377 _index = null; |
| 378 _subscription.resume(); | 378 _subscription.resume(); |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 } | 381 } |
| OLD | NEW |