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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 StreamController<List<int>> controller; | 99 StreamController<List<int>> controller; |
100 final StreamSubscription subscription; | 100 final StreamSubscription subscription; |
101 | 101 |
102 List<int> carryOverData; | 102 List<int> carryOverData; |
103 bool paused; | 103 bool paused; |
104 | 104 |
105 Completer resumeCompleter; | 105 Completer resumeCompleter; |
106 | 106 |
107 _HttpDetachedIncoming(StreamSubscription this.subscription, | 107 _HttpDetachedIncoming(StreamSubscription this.subscription, |
108 List<int> this.carryOverData) { | 108 List<int> this.carryOverData) { |
109 controller = new StreamController<List<int>>( | 109 controller = new StreamController<List<int>>(sync: true, |
floitsch
2013/05/30 12:13:48
move to next line.
Lasse Reichstein Nielsen
2013/05/31 05:51:59
Done.
| |
110 onListen: resume, | 110 onListen: resume, |
111 onPause: pause, | 111 onPause: pause, |
112 onResume: resume, | 112 onResume: resume, |
113 onCancel: () => subscription.cancel()); | 113 onCancel: () => subscription.cancel()); |
114 if (subscription == null) { | 114 if (subscription == null) { |
115 // Socket was already closed. | 115 // Socket was already closed. |
116 if (carryOverData != null) controller.add(carryOverData); | 116 if (carryOverData != null) controller.add(carryOverData); |
117 controller.close(); | 117 controller.close(); |
118 } else { | 118 } else { |
119 pause(); | 119 pause(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 | 187 |
188 factory _HttpParser.requestParser() { | 188 factory _HttpParser.requestParser() { |
189 return new _HttpParser._(true); | 189 return new _HttpParser._(true); |
190 } | 190 } |
191 | 191 |
192 factory _HttpParser.responseParser() { | 192 factory _HttpParser.responseParser() { |
193 return new _HttpParser._(false); | 193 return new _HttpParser._(false); |
194 } | 194 } |
195 | 195 |
196 _HttpParser._(this._requestParser) { | 196 _HttpParser._(this._requestParser) { |
197 _controller = new StreamController<_HttpIncoming>( | 197 _controller = new StreamController<_HttpIncoming>(sync: true, |
floitsch
2013/05/30 12:13:48
move to next line.
Lasse Reichstein Nielsen
2013/05/31 05:51:59
Done.
| |
198 onListen: () { | 198 onListen: () { |
199 _socketSubscription.resume(); | 199 _socketSubscription.resume(); |
200 _paused = false; | 200 _paused = false; |
201 }, | 201 }, |
202 onPause: () { | 202 onPause: () { |
203 _paused = true; | 203 _paused = true; |
204 _pauseStateChanged(); | 204 _pauseStateChanged(); |
205 }, | 205 }, |
206 onResume: () { | 206 onResume: () { |
207 _paused = false; | 207 _paused = false; |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 } else { | 875 } else { |
876 throw new HttpParserException("Failed to parse HTTP"); | 876 throw new HttpParserException("Failed to parse HTTP"); |
877 } | 877 } |
878 } | 878 } |
879 | 879 |
880 void _createIncoming(int transferLength) { | 880 void _createIncoming(int transferLength) { |
881 assert(_incoming == null); | 881 assert(_incoming == null); |
882 assert(_bodyController == null); | 882 assert(_bodyController == null); |
883 assert(!_bodyPaused); | 883 assert(!_bodyPaused); |
884 var incoming; | 884 var incoming; |
885 _bodyController = new StreamController<List<int>>( | 885 _bodyController = new StreamController<List<int>>(sync: true, |
floitsch
2013/05/30 12:13:48
ditto.
Lasse Reichstein Nielsen
2013/05/31 05:51:59
Done.
| |
886 onListen: () { | 886 onListen: () { |
887 if (incoming != _incoming) return; | 887 if (incoming != _incoming) return; |
888 assert(_bodyPaused); | 888 assert(_bodyPaused); |
889 _bodyPaused = false; | 889 _bodyPaused = false; |
890 _pauseStateChanged(); | 890 _pauseStateChanged(); |
891 }, | 891 }, |
892 onPause: () { | 892 onPause: () { |
893 if (incoming != _incoming) return; | 893 if (incoming != _incoming) return; |
894 assert(!_bodyPaused); | 894 assert(!_bodyPaused); |
895 _bodyPaused = true; | 895 _bodyPaused = true; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
985 StreamController<_HttpIncoming> _controller; | 985 StreamController<_HttpIncoming> _controller; |
986 StreamController<List<int>> _bodyController; | 986 StreamController<List<int>> _bodyController; |
987 } | 987 } |
988 | 988 |
989 | 989 |
990 class HttpParserException implements Exception { | 990 class HttpParserException implements Exception { |
991 const HttpParserException([String this.message = ""]); | 991 const HttpParserException([String this.message = ""]); |
992 String toString() => "HttpParserException: $message"; | 992 String toString() => "HttpParserException: $message"; |
993 final String message; | 993 final String message; |
994 } | 994 } |
OLD | NEW |