From a5cc6d48a46de61257186d41fd51ca95333fb573 Mon Sep 17 00:00:00 2001 From: serr Date: Sun, 6 Apr 2025 17:14:35 +0300 Subject: [PATCH] sendliminal fixed --- mvc/controllers/pages/main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mvc/controllers/pages/main.go b/mvc/controllers/pages/main.go index 1d05d2b..1275f67 100644 --- a/mvc/controllers/pages/main.go +++ b/mvc/controllers/pages/main.go @@ -76,20 +76,21 @@ func SendLove(w http.ResponseWriter) { // Ответ на метод LIMINAL func SendLiminal(w http.ResponseWriter) { w.Header().Set("Content-Type", "text/plain; charset=utf-8") + w.Header().Set("X-Accel-Buffering", "no") // важно для nginx w.WriteHeader(http.StatusOK) text := "If you're not careful and you slip out of reality in the wrong place, you'll end up in the Backstage, where there's nothing but the stench of old damp carpet, yellow-colored madness, the endless unbearable hum of fluorescent lights, and roughly six hundred million square miles of randomly arranged empty rooms." - // Создаем флашер для постепенной отправки flusher, ok := w.(http.Flusher) if !ok { - // Если флашинг не поддерживается, отправится сразу весь текст w.Write([]byte(text)) return } for _, char := range text { - w.Write([]byte(string(char))) + if _, err := w.Write([]byte{byte(char)}); err != nil { + return + } flusher.Flush() time.Sleep(50 * time.Millisecond) }