RPRX 2025-01-12 13:14:56 +00:00 committed by GitHub
parent 898b54b891
commit 014f5e6a09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 8 deletions

View File

@ -168,21 +168,20 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req
} else { } else {
writer.Header().Set("X-Accel-Buffering", "no") writer.Header().Set("X-Accel-Buffering", "no")
writer.Header().Set("Cache-Control", "no-store") writer.Header().Set("Cache-Control", "no-store")
if !h.config.NoSSEHeader {
writer.Header().Set("Content-Type", "text/event-stream")
}
writer.WriteHeader(http.StatusOK) writer.WriteHeader(http.StatusOK)
if request.ProtoMajor != 1 && len(clientVer) > 0 && clientVer[0] >= 25 { if request.ProtoMajor != 1 && len(clientVer) > 0 && clientVer[0] >= 25 {
go func() { go func() {
for { for {
paddingLen := h.config.GetNormalizedXPaddingBytes().rand() paddingLen := h.config.GetNormalizedXPaddingBytes().rand()
if paddingLen > 0 { if paddingLen <= 0 {
writer.(http.Flusher).Flush()
break
}
_, err := writer.Write(bytes.Repeat([]byte{'0'}, int(paddingLen))) _, err := writer.Write(bytes.Repeat([]byte{'0'}, int(paddingLen)))
if err != nil { if err != nil {
break break
} }
writer.(http.Flusher).Flush() writer.(http.Flusher).Flush()
}
time.Sleep(time.Duration(RangeConfig{From: 20, To: 80}.rand()) * time.Second) time.Sleep(time.Duration(RangeConfig{From: 20, To: 80}.rand()) * time.Second)
} }
}() }()