| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library http2.src.stream_handler; | 5 library http2.src.stream_handler; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:math'; | 8 import 'dart:math'; |
| 9 | 9 |
| 10 import '../../transport.dart'; | 10 import '../../transport.dart'; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 bool _isPeerInitiatedStream(int streamId) { | 191 bool _isPeerInitiatedStream(int streamId) { |
| 192 bool isServerStreamId = streamId.isEven; | 192 bool isServerStreamId = streamId.isEven; |
| 193 bool isLocalStream = isServerStreamId == isServer; | 193 bool isLocalStream = isServerStreamId == isServer; |
| 194 return !isLocalStream; | 194 return !isLocalStream; |
| 195 } | 195 } |
| 196 | 196 |
| 197 TransportStream newStream(List<Header> headers, {bool endStream: false}) { | 197 TransportStream newStream(List<Header> headers, {bool endStream: false}) { |
| 198 return ensureNotTerminatedSync(() { | 198 return ensureNotTerminatedSync(() { |
| 199 var stream = newLocalStream(); | 199 var stream = newLocalStream(); |
| 200 _sendHeaders(stream, headers); | 200 _sendHeaders(stream, headers, endStream: endStream); |
| 201 if (endStream) { | |
| 202 _handleOutgoingClose(stream); | |
| 203 } | |
| 204 return stream; | 201 return stream; |
| 205 }); | 202 }); |
| 206 } | 203 } |
| 207 | 204 |
| 208 TransportStream newLocalStream() { | 205 TransportStream newLocalStream() { |
| 209 return ensureNotTerminatedSync(() { | 206 return ensureNotTerminatedSync(() { |
| 210 assert(_canCreateNewStream()); | 207 assert(_canCreateNewStream()); |
| 211 | 208 |
| 212 if (MAX_STREAM_ID < nextStreamId) { | 209 if (MAX_STREAM_ID < nextStreamId) { |
| 213 throw new StateError( | 210 throw new StateError( |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 } | 791 } |
| 795 stream.state = to; | 792 stream.state = to; |
| 796 } | 793 } |
| 797 | 794 |
| 798 bool _didInitiateStream(Http2StreamImpl stream) { | 795 bool _didInitiateStream(Http2StreamImpl stream) { |
| 799 int id = stream.id; | 796 int id = stream.id; |
| 800 return (isServer && id.isEven) || (!isServer && id.isOdd); | 797 return (isServer && id.isEven) || (!isServer && id.isOdd); |
| 801 } | 798 } |
| 802 } | 799 } |
| 803 | 800 |
| OLD | NEW |