SplitHTTP server: Add noSSEHeader

https://github.com/XTLS/Xray-core/pull/3603#issuecomment-2254968219
This commit is contained in:
RPRX 2024-07-29 06:32:04 +00:00 committed by GitHub
parent 59f6685774
commit 60553a6c26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 46 additions and 29 deletions

View file

@ -26,6 +26,7 @@ import (
)
type requestHandler struct {
config *Config
host string
path string
ln *Listener
@ -182,8 +183,10 @@ 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")
if !h.config.NoSSEHeader {
// 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.
@ -267,6 +270,7 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet
var err error
var localAddr = gonet.TCPAddr{}
handler := &requestHandler{
config: shSettings,
host: shSettings.Host,
path: shSettings.GetNormalizedPath("", false),
ln: l,