Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: sdk/lib/io/http_impl.dart

Issue 11299228: Add HttpsServer class and test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/https_server_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index c78348120f47f71707b21bc1294a9265091b81a1..a5a830885fae8c3eaba31d4166d27c5dd3ada7b4 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -925,13 +925,29 @@ class _RequestHandlerRegistration {
// HTTP server waiting for socket connections. The connections are
// managed by the server and as requests are received the request.
-class _HttpServer implements HttpServer {
- _HttpServer() : _connections = new Set<_HttpConnection>(),
- _handlers = new List<_RequestHandlerRegistration>(),
- _closeQueue = new _CloseQueue();
-
- void listen(String host, int port, {int backlog: 128}) {
- listenOn(new ServerSocket(host, port, backlog));
+// HTTPS connections are also supported, if the _HttpServer.httpsServer
+// constructor is used and a certificate name is provided in listen,
+// or a SecureServerSocket is provided to listenOn.
+class _HttpServer implements HttpServer, HttpsServer {
+ _HttpServer() : this._internal(isSecure: false);
+
+ _HttpServer.httpsServer() : this._internal(isSecure: true);
+
+ _HttpServer._internal({ bool isSecure: false })
+ : _secure = isSecure,
+ _connections = new Set<_HttpConnection>(),
+ _handlers = new List<_RequestHandlerRegistration>(),
+ _closeQueue = new _CloseQueue();
+
+ void listen(String host,
+ int port,
+ {int backlog: 128,
+ String certificate_name}) {
+ if (_secure) {
+ listenOn(new SecureServerSocket(host, port, backlog, certificate_name));
+ } else {
+ listenOn(new ServerSocket(host, port, backlog));
+ }
_closeServer = true;
}
@@ -1051,6 +1067,7 @@ class _HttpServer implements HttpServer {
ServerSocket _server; // The server listen socket.
bool _closeServer = false;
+ bool _secure;
Set<_HttpConnection> _connections; // Set of currently connected clients.
List<_RequestHandlerRegistration> _handlers;
Object _defaultHandler;
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/https_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698