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) }