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 _OUTGOING_BUFFER_SIZE = 8 * 1024; | 7 const int _OUTGOING_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 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 | 2183 |
2184 InternetAddress get address { | 2184 InternetAddress get address { |
2185 if (closed) throw new HttpException("HttpServer is not bound to a socket"); | 2185 if (closed) throw new HttpException("HttpServer is not bound to a socket"); |
2186 return _serverSocket.address; | 2186 return _serverSocket.address; |
2187 } | 2187 } |
2188 | 2188 |
2189 set sessionTimeout(int timeout) { | 2189 set sessionTimeout(int timeout) { |
2190 _sessionManager.sessionTimeout = timeout; | 2190 _sessionManager.sessionTimeout = timeout; |
2191 } | 2191 } |
2192 | 2192 |
2193 void _handleRequest(HttpRequest request) => _controller.add(request); | 2193 void _handleRequest(_HttpRequest request) { |
| 2194 // Delay the request until the isolate's message-queue is handled. |
| 2195 // This greatly improves scheduling when a lot of requests are active. |
| 2196 Timer.run(() { |
| 2197 if (!closed) { |
| 2198 _controller.add(request); |
| 2199 } else { |
| 2200 request._httpConnection.destroy(); |
| 2201 } |
| 2202 }); |
| 2203 } |
2194 | 2204 |
2195 void _handleError(error) { | 2205 void _handleError(error) { |
2196 if (!closed) _controller.addError(error); | 2206 if (!closed) _controller.addError(error); |
2197 } | 2207 } |
2198 | 2208 |
2199 void _connectionClosed(_HttpConnection connection) { | 2209 void _connectionClosed(_HttpConnection connection) { |
2200 // Remove itself from either idle or active connections. | 2210 // Remove itself from either idle or active connections. |
2201 connection.unlink(); | 2211 connection.unlink(); |
2202 _maybePerformCleanup(); | 2212 _maybePerformCleanup(); |
2203 } | 2213 } |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2690 const _RedirectInfo(this.statusCode, this.method, this.location); | 2700 const _RedirectInfo(this.statusCode, this.method, this.location); |
2691 } | 2701 } |
2692 | 2702 |
2693 String _getHttpVersion() { | 2703 String _getHttpVersion() { |
2694 var version = Platform.version; | 2704 var version = Platform.version; |
2695 // Only include major and minor version numbers. | 2705 // Only include major and minor version numbers. |
2696 int index = version.indexOf('.', version.indexOf('.') + 1); | 2706 int index = version.indexOf('.', version.indexOf('.') + 1); |
2697 version = version.substring(0, index); | 2707 version = version.substring(0, index); |
2698 return 'Dart/$version (dart:io)'; | 2708 return 'Dart/$version (dart:io)'; |
2699 } | 2709 } |
OLD | NEW |