| 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 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2153 // Use default Map so we keep order. | 2153 // Use default Map so we keep order. |
| 2154 static Map<int, _HttpServer> _servers = new Map<int, _HttpServer>(); | 2154 static Map<int, _HttpServer> _servers = new Map<int, _HttpServer>(); |
| 2155 | 2155 |
| 2156 String serverHeader; | 2156 String serverHeader; |
| 2157 final HttpHeaders defaultResponseHeaders = _initDefaultResponseHeaders(); | 2157 final HttpHeaders defaultResponseHeaders = _initDefaultResponseHeaders(); |
| 2158 bool autoCompress = false; | 2158 bool autoCompress = false; |
| 2159 | 2159 |
| 2160 Duration _idleTimeout; | 2160 Duration _idleTimeout; |
| 2161 Timer _idleTimer; | 2161 Timer _idleTimer; |
| 2162 | 2162 |
| 2163 static Future<HttpServer> bind(address, int port, int backlog) { | 2163 static Future<HttpServer> bind( |
| 2164 return ServerSocket.bind(address, port, backlog: backlog).then((socket) { | 2164 address, int port, int backlog, bool v6Only, bool shared) { |
| 2165 return new _HttpServer._(socket, true); | 2165 return ServerSocket.bind( |
| 2166 }); | 2166 address, port, backlog: backlog, v6Only: v6Only, shared: shared) |
| 2167 .then((socket) { |
| 2168 return new _HttpServer._(socket, true); |
| 2169 }); |
| 2167 } | 2170 } |
| 2168 | 2171 |
| 2169 static Future<HttpServer> bindSecure(address, | 2172 static Future<HttpServer> bindSecure(address, |
| 2170 int port, | 2173 int port, |
| 2171 int backlog, | 2174 int backlog, |
| 2175 bool v6Only, |
| 2172 String certificate_name, | 2176 String certificate_name, |
| 2173 bool requestClientCertificate) { | 2177 bool requestClientCertificate, |
| 2178 bool shared) { |
| 2174 return SecureServerSocket.bind( | 2179 return SecureServerSocket.bind( |
| 2175 address, | 2180 address, |
| 2176 port, | 2181 port, |
| 2177 certificate_name, | 2182 certificate_name, |
| 2178 backlog: backlog, | 2183 backlog: backlog, |
| 2179 requestClientCertificate: requestClientCertificate) | 2184 v6Only: v6Only, |
| 2180 .then((socket) { | 2185 requestClientCertificate: requestClientCertificate, |
| 2181 return new _HttpServer._(socket, true); | 2186 shared: shared) |
| 2182 }); | 2187 .then((socket) { |
| 2188 return new _HttpServer._(socket, true); |
| 2189 }); |
| 2183 } | 2190 } |
| 2184 | 2191 |
| 2185 _HttpServer._(this._serverSocket, this._closeServer) { | 2192 _HttpServer._(this._serverSocket, this._closeServer) { |
| 2186 _controller = new StreamController<HttpRequest>(sync: true, | 2193 _controller = new StreamController<HttpRequest>(sync: true, |
| 2187 onCancel: close); | 2194 onCancel: close); |
| 2188 idleTimeout = const Duration(seconds: 120); | 2195 idleTimeout = const Duration(seconds: 120); |
| 2189 _servers[_serviceId] = this; | 2196 _servers[_serviceId] = this; |
| 2190 _serverSocket._owner = this; | 2197 _serverSocket._owner = this; |
| 2191 } | 2198 } |
| 2192 | 2199 |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2809 const _RedirectInfo(this.statusCode, this.method, this.location); | 2816 const _RedirectInfo(this.statusCode, this.method, this.location); |
| 2810 } | 2817 } |
| 2811 | 2818 |
| 2812 String _getHttpVersion() { | 2819 String _getHttpVersion() { |
| 2813 var version = Platform.version; | 2820 var version = Platform.version; |
| 2814 // Only include major and minor version numbers. | 2821 // Only include major and minor version numbers. |
| 2815 int index = version.indexOf('.', version.indexOf('.') + 1); | 2822 int index = version.indexOf('.', version.indexOf('.') + 1); |
| 2816 version = version.substring(0, index); | 2823 version = version.substring(0, index); |
| 2817 return 'Dart/$version (dart:io)'; | 2824 return 'Dart/$version (dart:io)'; |
| 2818 } | 2825 } |
| OLD | NEW |