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 const int _HEADERS_BUFFER_SIZE = 8 * 1024; | 7 const int _HEADERS_BUFFER_SIZE = 8 * 1024; |
8 | 8 |
9 class _HttpIncoming extends Stream<List<int>> { | 9 class _HttpIncoming extends Stream<List<int>> { |
10 final int _transferLength; | 10 final int _transferLength; |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 579 |
580 void _cancel() { | 580 void _cancel() { |
581 if (_subscription != null) { | 581 if (_subscription != null) { |
582 StreamSubscription subscription = _subscription; | 582 StreamSubscription subscription = _subscription; |
583 _subscription = null; | 583 _subscription = null; |
584 subscription.cancel(); | 584 subscription.cancel(); |
585 } | 585 } |
586 } | 586 } |
587 | 587 |
588 bool _ignoreError(error) | 588 bool _ignoreError(error) |
589 => error is SocketException && _outbound is HttpResponse; | 589 => (error is SocketException || error is TlsException) && |
| 590 _outbound is HttpResponse; |
590 | 591 |
591 _ensureController() { | 592 _ensureController() { |
592 if (_controller != null) return; | 593 if (_controller != null) return; |
593 _controller = new StreamController(sync: true, | 594 _controller = new StreamController(sync: true, |
594 onPause: () => _subscription.pause(), | 595 onPause: () => _subscription.pause(), |
595 onResume: () => _subscription.resume(), | 596 onResume: () => _subscription.resume(), |
596 onListen: () => _subscription.resume(), | 597 onListen: () => _subscription.resume(), |
597 onCancel: _cancel); | 598 onCancel: _cancel); |
598 _outbound._addStream(_controller.stream) | 599 _outbound._addStream(_controller.stream) |
599 .then((_) { | 600 .then((_) { |
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 {Function onError, | 2049 {Function onError, |
2049 void onDone(), | 2050 void onDone(), |
2050 bool cancelOnError}) { | 2051 bool cancelOnError}) { |
2051 _serverSocket.listen( | 2052 _serverSocket.listen( |
2052 (Socket socket) { | 2053 (Socket socket) { |
2053 socket.setOption(SocketOption.TCP_NODELAY, true); | 2054 socket.setOption(SocketOption.TCP_NODELAY, true); |
2054 // Accept the client connection. | 2055 // Accept the client connection. |
2055 _HttpConnection connection = new _HttpConnection(socket, this); | 2056 _HttpConnection connection = new _HttpConnection(socket, this); |
2056 _connections.add(connection); | 2057 _connections.add(connection); |
2057 }, | 2058 }, |
2058 onError: _controller.addError, | 2059 onError: (error) { |
| 2060 // Ignore HandshakeExceptions as they are bound to a single request, |
| 2061 // and are not fatal for the server. |
| 2062 if (error is! HandshakeException) { |
| 2063 _controller.addError(error); |
| 2064 } |
| 2065 }, |
2059 onDone: _controller.close); | 2066 onDone: _controller.close); |
2060 return _controller.stream.listen(onData, | 2067 return _controller.stream.listen(onData, |
2061 onError: onError, | 2068 onError: onError, |
2062 onDone: onDone, | 2069 onDone: onDone, |
2063 cancelOnError: cancelOnError); | 2070 cancelOnError: cancelOnError); |
2064 } | 2071 } |
2065 | 2072 |
2066 Future close({bool force: false}) { | 2073 Future close({bool force: false}) { |
2067 closed = true; | 2074 closed = true; |
2068 Future result; | 2075 Future result; |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2570 | 2577 |
2571 String _getHttpVersion() { | 2578 String _getHttpVersion() { |
2572 var version = Platform.version; | 2579 var version = Platform.version; |
2573 // Only include major and minor version numbers. | 2580 // Only include major and minor version numbers. |
2574 int index = version.indexOf('.', version.indexOf('.') + 1); | 2581 int index = version.indexOf('.', version.indexOf('.') + 1); |
2575 version = version.substring(0, index); | 2582 version = version.substring(0, index); |
2576 return 'Dart/$version (dart:io)'; | 2583 return 'Dart/$version (dart:io)'; |
2577 } | 2584 } |
2578 | 2585 |
2579 | 2586 |
OLD | NEW |