sendliminal fixed
parent
286e31f1f7
commit
a5cc6d48a4
|
@ -76,20 +76,21 @@ func SendLove(w http.ResponseWriter) {
|
||||||
// Ответ на метод LIMINAL
|
// Ответ на метод LIMINAL
|
||||||
func SendLiminal(w http.ResponseWriter) {
|
func SendLiminal(w http.ResponseWriter) {
|
||||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||||
|
w.Header().Set("X-Accel-Buffering", "no") // важно для nginx
|
||||||
w.WriteHeader(http.StatusOK)
|
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."
|
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)
|
flusher, ok := w.(http.Flusher)
|
||||||
if !ok {
|
if !ok {
|
||||||
// Если флашинг не поддерживается, отправится сразу весь текст
|
|
||||||
w.Write([]byte(text))
|
w.Write([]byte(text))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, char := range text {
|
for _, char := range text {
|
||||||
w.Write([]byte(string(char)))
|
if _, err := w.Write([]byte{byte(char)}); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
flusher.Flush()
|
flusher.Flush()
|
||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue