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