From d0b94648962ce1f89dd9dc519004f45a695ea780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=2E=20R=C3=B8dseth?= Date: Tue, 15 Oct 2024 11:02:01 +0200 Subject: [PATCH] Add test files --- engine/handlers.go | 10 ++++++++++ samples/www/index.lua | 5 +++++ 2 files changed, 15 insertions(+) create mode 100644 samples/www/index.lua diff --git a/engine/handlers.go b/engine/handlers.go index dd837d98..dc678f9a 100644 --- a/engine/handlers.go +++ b/engine/handlers.go @@ -290,10 +290,15 @@ func (ac *Config) FilePage(w http.ResponseWriter, req *http.Request, filename, l } else { recorder.WriteHeader(http.StatusOK) } + w.Header().Set("Connection", "Keep-Alive") + w.Header().Set("X-Content-Type-Options", "nosniff") + w.Header().Set("Content-Type", "text/html") // Then write to the ResponseWriter utils.WriteRecorder(w, recorder) // WriteRecorder starts out by writing the status header if flusher, ok := w.(http.Flusher); ok { flusher.Flush() + } else { + logrus.Error("NO FLUSHER") } } // Run the lua script, without the possibility to flush @@ -323,8 +328,13 @@ func (ac *Config) FilePage(w http.ResponseWriter, req *http.Request, filename, l // The flush function just flushes the ResponseWriter flushFunc := func() { w.WriteHeader(http.StatusOK) + w.Header().Set("Connection", "Keep-Alive") + w.Header().Set("X-Content-Type-Options", "nosniff") + w.Header().Set("Content-Type", "text/html") if flusher, ok := w.(http.Flusher); ok { flusher.Flush() + } else { + logrus.Error("NO FLUSHER") } } // Run the lua script, with the flush feature diff --git a/samples/www/index.lua b/samples/www/index.lua new file mode 100644 index 00000000..2ad2a7c8 --- /dev/null +++ b/samples/www/index.lua @@ -0,0 +1,5 @@ +print("hi") +flush() +--close() +sleep(5) +print("done")