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 class _HttpIncoming extends Stream<List<int>> { | 7 class _HttpIncoming extends Stream<List<int>> { |
8 final int _transferLength; | 8 final int _transferLength; |
9 final Completer _dataCompleter = new Completer(); | 9 final Completer _dataCompleter = new Completer(); |
10 Stream<List<int>> _stream; | 10 Stream<List<int>> _stream; |
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 _connections.add(connection); | 1919 _connections.add(connection); |
1920 }, | 1920 }, |
1921 onError: _controller.addError, | 1921 onError: _controller.addError, |
1922 onDone: _controller.close); | 1922 onDone: _controller.close); |
1923 return _controller.stream.listen(onData, | 1923 return _controller.stream.listen(onData, |
1924 onError: onError, | 1924 onError: onError, |
1925 onDone: onDone, | 1925 onDone: onDone, |
1926 cancelOnError: cancelOnError); | 1926 cancelOnError: cancelOnError); |
1927 } | 1927 } |
1928 | 1928 |
1929 void close() { | 1929 Future close() { |
1930 closed = true; | 1930 closed = true; |
| 1931 Future result; |
1931 if (_serverSocket != null && _closeServer) { | 1932 if (_serverSocket != null && _closeServer) { |
1932 _serverSocket.close(); | 1933 result = _serverSocket.close(); |
| 1934 } else { |
| 1935 result = new Future.value(); |
1933 } | 1936 } |
1934 if (_sessionManagerInstance != null) { | 1937 if (_sessionManagerInstance != null) { |
1935 _sessionManagerInstance.close(); | 1938 _sessionManagerInstance.close(); |
1936 _sessionManagerInstance = null; | 1939 _sessionManagerInstance = null; |
1937 } | 1940 } |
1938 for (_HttpConnection connection in _connections.toList()) { | 1941 for (_HttpConnection connection in _connections.toList()) { |
1939 connection.destroy(); | 1942 connection.destroy(); |
1940 } | 1943 } |
1941 _connections.clear(); | 1944 _connections.clear(); |
| 1945 return result; |
1942 } | 1946 } |
1943 | 1947 |
1944 int get port { | 1948 int get port { |
1945 if (closed) throw new HttpException("HttpServer is not bound to a socket"); | 1949 if (closed) throw new HttpException("HttpServer is not bound to a socket"); |
1946 return _serverSocket.port; | 1950 return _serverSocket.port; |
1947 } | 1951 } |
1948 | 1952 |
1949 set sessionTimeout(int timeout) { | 1953 set sessionTimeout(int timeout) { |
1950 _sessionManager.sessionTimeout = timeout; | 1954 _sessionManager.sessionTimeout = timeout; |
1951 } | 1955 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 final Uri location; | 2408 final Uri location; |
2405 } | 2409 } |
2406 | 2410 |
2407 String _getHttpVersion() { | 2411 String _getHttpVersion() { |
2408 var version = Platform.version; | 2412 var version = Platform.version; |
2409 // Only include major and minor version numbers. | 2413 // Only include major and minor version numbers. |
2410 int index = version.indexOf('.', version.indexOf('.') + 1); | 2414 int index = version.indexOf('.', version.indexOf('.') + 1); |
2411 version = version.substring(0, index); | 2415 version = version.substring(0, index); |
2412 return 'Dart/$version (dart:io)'; | 2416 return 'Dart/$version (dart:io)'; |
2413 } | 2417 } |
OLD | NEW |