From c0f3bf66fd2ee0850ccc3842f09cba624fce5547 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Fri, 28 Jun 2024 09:35:53 +0200 Subject: [PATCH] Add new header to disable HTTP middle box buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: 风扇滑翔翼 --- transport/internet/splithttp/hub.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 5181b19b..1e586eef 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -161,6 +161,9 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req // magic header instructs nginx + apache to not buffer response body writer.Header().Set("X-Accel-Buffering", "no") + // magic header to make the HTTP middle box consider this as SSE to disable buffer + writer.Header().Set("Content-Type", "text/event-stream") + writer.WriteHeader(http.StatusOK) // send a chunk immediately to enable CDN streaming. // many CDN buffer the response headers until the origin starts sending