瀏覽代碼

Add new header to disable HTTP middle box buffer

Co-Authored-By: 风扇滑翔翼 <[email protected]>
mmmray 1 年之前
父節點
當前提交
c0f3bf66fd
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      transport/internet/splithttp/hub.go

+ 3 - 0
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