OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Global constants. | 7 // Global constants. |
8 class _Const { | 8 class _Const { |
9 // Bytes for "HTTP". | 9 // Bytes for "HTTP". |
10 static const HTTP = const [72, 84, 84, 80]; | 10 static const HTTP = const [72, 84, 84, 80]; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 | 203 |
204 _HttpParser._(this._requestParser) { | 204 _HttpParser._(this._requestParser) { |
205 _controller = new StreamController<_HttpIncoming>( | 205 _controller = new StreamController<_HttpIncoming>( |
206 onSubscriptionStateChange: _updateParsePauseState, | 206 onSubscriptionStateChange: _updateParsePauseState, |
207 onPauseStateChange: _updateParsePauseState); | 207 onPauseStateChange: _updateParsePauseState); |
208 _reset(); | 208 _reset(); |
209 } | 209 } |
210 | 210 |
211 | 211 |
212 StreamSubscription<_HttpIncoming> listen(void onData(List<int> event), | 212 StreamSubscription<_HttpIncoming> listen(void onData(_HttpIncoming event), |
213 {void onError(AsyncError error), | 213 {void onError(AsyncError error), |
214 void onDone(), | 214 void onDone(), |
215 bool unsubscribeOnError}) { | 215 bool unsubscribeOnError}) { |
216 return _controller.stream.listen(onData, | 216 return _controller.stream.listen(onData, |
217 onError: onError, | 217 onError: onError, |
218 onDone: onDone, | 218 onDone: onDone, |
219 unsubscribeOnError: unsubscribeOnError); | 219 unsubscribeOnError: unsubscribeOnError); |
220 } | 220 } |
221 | 221 |
222 Future<_HttpParser> consume(Stream<List<int>> stream) { | 222 Future<_HttpParser> consume(Stream<List<int>> stream) { |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 StreamController<_HttpIncoming> _controller; | 956 StreamController<_HttpIncoming> _controller; |
957 StreamController<List<int>> _bodyController; | 957 StreamController<List<int>> _bodyController; |
958 } | 958 } |
959 | 959 |
960 | 960 |
961 class HttpParserException implements Exception { | 961 class HttpParserException implements Exception { |
962 const HttpParserException([String this.message = ""]); | 962 const HttpParserException([String this.message = ""]); |
963 String toString() => "HttpParserException: $message"; | 963 String toString() => "HttpParserException: $message"; |
964 final String message; | 964 final String message; |
965 } | 965 } |
OLD | NEW |