Commit dc8661cfa3f52e8fa71b0285b95adc76b3aeca8a

Thomas de Grivel 2024-09-16T04:10:48

httpd: Last-Modified header

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/lib/kc3/0.1/httpd.kc3 b/lib/kc3/0.1/httpd.kc3
index 5c795b7..54a2d5a 100644
--- a/lib/kc3/0.1/httpd.kc3
+++ b/lib/kc3/0.1/httpd.kc3
@@ -217,8 +217,10 @@ defmodule HTTPd do
     if File.exists?(path) do
       mime = HTTP.mime_type(ext)
       stat = File.stat(path)
+      last_modified = Str.ftime(stat.st_mtim, "%a, %d %b %G %T %Z")
       headers = [{"Content-Type", (Str) mime},
-                 {"Content-Length", (Str) stat.st_size} ]
+                 {"Content-Length", (Str) stat.st_size},
+                 {"Last-Modified", last_modified}]
       body = File.open_r(path)
       %HTTP.Response{body: body, headers: headers}
     else