misc updates to server code; improve Cache-Control settings

This commit is contained in:
2025-05-11 15:31:09 -07:00
parent c84e04e784
commit 10f7e9bebb
3 changed files with 15 additions and 15 deletions

View File

@ -16,11 +16,11 @@
(.bind socket #(ADDRESS PORT))
(.listen socket 10)
(.debug log "socket bound")
(while True
(try
(.start
(Thread
(try
(.start
(Thread
:target (fn [client-socket address]
(try
(setv request-data (bytes))
@ -28,7 +28,7 @@
(+= request-data data)
(when (< (len data) 1024)
(break)))
(setv parsed-request (http.request.parse-data request-data))
(.debug log parsed-request)
(.info log (+ (str (cond
@ -37,19 +37,19 @@
(setv response (match-request parsed-request))
(.sendall client-socket (http.response.send #** response))
(except [e Exception]
(.warn log (format-exc))
(.close client-socket))))
:args #(#* (socket.accept))))
(except [e Exception]
(.warn log (format-exc)))))
(except [e Exception]
(.critical log (format-exc)))
(finally
(.close socket)
(.info log "server shut down")))))