Skip to content

Commit

Permalink
Add new header to disable HTTP middle box buffer
Browse files Browse the repository at this point in the history
Co-Authored-By: 风扇滑翔翼 <[email protected]>
  • Loading branch information
mmmray and Fangliding committed Jun 28, 2024
1 parent e4f9d03 commit c0f3bf6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions transport/internet/splithttp/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c0f3bf6

Please sign in to comment.