feat: upate secure_server/simple_secure_server.dart
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
# ---> Dart
|
||||
# See https://www.dartlang.org/guides/libraries/private-files
|
||||
|
||||
.idea/
|
||||
# Files and directories created by pub
|
||||
.dart_tool/
|
||||
.packages
|
||||
|
||||
@@ -5,19 +5,22 @@ String serverKey = 'server_key.pem';
|
||||
|
||||
Future main() async {
|
||||
var serverContext = SecurityContext();
|
||||
serverContext.useCertificateChain(certificateChain);
|
||||
serverContext.usePrivateKey(serverKey, password: 'dartdart');
|
||||
serverContext
|
||||
..useCertificateChain(certificateChain)
|
||||
..usePrivateKey(serverKey, password: 'dartdart');
|
||||
|
||||
var server = await HttpServer.bindSecure(
|
||||
'0.0.0.0',
|
||||
8443,
|
||||
serverContext,
|
||||
);
|
||||
print('Listening on localhost:${server.port}');
|
||||
print('[INFO] Listening on localhost:${server.port} for HTTPS requests');
|
||||
await for (HttpRequest request in server) {
|
||||
print('Got request for ${request.uri.path}');
|
||||
print('[INFO] Got request for ${request.uri.path}');
|
||||
request.response
|
||||
..write('Hello, world!')
|
||||
..statusCode = 200
|
||||
..headers.add("content-type", "text/plain; charset=utf-8")
|
||||
..write('Hello, world!\n')
|
||||
..close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user