From 70bea2d606ff126c0617e5ce7b51946c1c14953c Mon Sep 17 00:00:00 2001 From: Classy-Bear Date: Sat, 26 Sep 2020 01:42:14 -0400 Subject: [PATCH 1/3] Fix known issues: Tutorial 'Write HTTP clients & servers' doesn't work as expected #2646 --- httpserver/bin/mini_file_server.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/httpserver/bin/mini_file_server.dart b/httpserver/bin/mini_file_server.dart index 2e8bff6..864ddcb 100644 --- a/httpserver/bin/mini_file_server.dart +++ b/httpserver/bin/mini_file_server.dart @@ -32,6 +32,7 @@ Future main() async { req.response.headers.contentType = ContentType.html; try { await req.response.addStream(targetFile.openRead()); + await req.response.close(); } catch (e) { print("Couldn't read file: $e"); exit(-1); From 58736460c1a47158c998bbdecdbf6f253d2d3fe3 Mon Sep 17 00:00:00 2001 From: David Acevedo Date: Sat, 26 Sep 2020 01:56:43 -0400 Subject: [PATCH 2/3] Indentation fixed The wrong indentation was caused by VIM. --- httpserver/bin/mini_file_server.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpserver/bin/mini_file_server.dart b/httpserver/bin/mini_file_server.dart index 864ddcb..4c90e66 100644 --- a/httpserver/bin/mini_file_server.dart +++ b/httpserver/bin/mini_file_server.dart @@ -32,7 +32,7 @@ Future main() async { req.response.headers.contentType = ContentType.html; try { await req.response.addStream(targetFile.openRead()); - await req.response.close(); + await req.response.close(); } catch (e) { print("Couldn't read file: $e"); exit(-1); From 6c9a13bc1ca57be173f0ff52c8f88db261f5c9b8 Mon Sep 17 00:00:00 2001 From: David Acevedo Date: Sat, 26 Sep 2020 02:22:54 -0400 Subject: [PATCH 3/3] Eliminating redundancy --- httpserver/bin/mini_file_server.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpserver/bin/mini_file_server.dart b/httpserver/bin/mini_file_server.dart index 4c90e66..05f481b 100644 --- a/httpserver/bin/mini_file_server.dart +++ b/httpserver/bin/mini_file_server.dart @@ -32,7 +32,6 @@ Future main() async { req.response.headers.contentType = ContentType.html; try { await req.response.addStream(targetFile.openRead()); - await req.response.close(); } catch (e) { print("Couldn't read file: $e"); exit(-1); @@ -40,7 +39,7 @@ Future main() async { } else { print("Can't open ${targetFile.path}."); req.response.statusCode = HttpStatus.notFound; - await req.response.close(); } + await req.response.close(); } }